<?php
//商品分类
$clist = db('shop_category')->field('id,name,pic')->where('aid',aid)->where('status',1)->where('pid',0)->order('sort desc,id')->select()->toArray();
foreach($clist as $k=>$v){
	$clist[$k]['child'] = db('shop_category')->field('id,name,pic')->where('aid',aid)->where('status',1)->where('pid',$v['id'])->order('sort desc,id')->select()->toArray();
}
if($bid > 0){
	$clist2 = db('shop_category2')->field('id,name,pic')->where('aid',aid)->where('bid',$bid)->where('status',1)->where('pid',0)->order('sort desc,id')->select()->toArray();
	foreach($clist2 as $k=>$v){
		$clist2[$k]['child'] = db('shop_category2')->field('id,name,pic')->where('aid',aid)->where('bid',$bid)->where('status',1)->where('pid',$v['id'])->order('sort desc,id')->select()->toArray();
	}
}
//商品分组
$glist = db('shop_group')->where('aid',aid)->order('sort desc,id')->select()->toArray();
$gids = [0=>true];
foreach($glist as $g){
	$gids[$g['id']] = true;
}
//文章分类
$aclist = db('article_category')->field('id,name,pic')->where('aid',aid)->where('bid',$bid)->where('status',1)->where('pid',0)->order('sort desc,id')->select()->toArray();
foreach($aclist as $k=>$v){
	$aclist[$k]['child'] = db('article_category')->field('id,name,pic')->where('aid',aid)->where('status',1)->where('pid',$v['id'])->order('sort desc,id')->select()->toArray();
}
$default_cid = db('member_level_category')->where('aid',aid)->where('isdefault', 1)->value('id');
$default_cid = $default_cid ? $default_cid : 0;
$memberlevelList = db('member_level')->where('aid',aid)->where('cid',$default_cid)->order('sort,id')->select()->toArray();
//拼团分类
$collage_clist = db('collage_category')->field('id,name,pic')->where('aid',aid)->where('status',1)->where('pid',0)->order('sort desc,id')->select()->toArray();

//预约分类
$yuyue_clist = db('yuyue_category')->field('id,name,pic')->where('aid',aid)->where('bid',$bid)->where('status',1)->where('pid',0)->order('sort desc,id')->select()->toArray();

foreach($yuyue_clist as $k=>$v){
	$yuyue_clist[$k]['child'] = db('yuyue_category')->field('id,name,pic')->where('aid',aid)->where('status',1)->where('pid',$v['id'])->order('sort desc,id')->select()->toArray();
}
if($bid == 0){
	//积分兑换分类
	$scoreshop_clist = db('scoreshop_category')->field('id,name,pic')->where('aid',aid)->where('status',1)->where('pid',0)->order('sort desc,id')->select()->toArray();
	//商家分类
	$blist = db('business_category')->field('id,name,pic')->where('aid',aid)->where('status',1)->order('sort desc,id')->select()->toArray();
	//商家
	$bnlist = db('business')->field('id,name,logo,address')->where('aid',aid)->where('status',1)->order('sort desc,id')->select()->toArray();
}
$shortvideo_clist = db('shortvideo_category')->where('aid',aid)->where('bid',$bid)->where('status',1)->order('sort desc,id')->select()->toArray();

//幸运拼团分类
$luckycollage_clist = db('lucky_collage_category')->field('id,name,pic')->where('aid',aid)->where('status',1)->where('pid',0)->order('sort desc,id')->select()->toArray();

//团购分类
$tuangou_clist = db('tuangou_category')->field('id,name,pic')->where('aid',aid)->where('status',1)->where('pid',0)->order('sort desc,id')->select()->toArray();

//课程类型
$kecheng_clist = db('kecheng_category')->field('id,name,pic')->where('aid',aid)->where('bid',$bid)->where('status',1)->where('pid',0)->order('sort desc,id')->select()->toArray();
foreach($kecheng_clist as $k=>$v){
	$kecheng_clist[$k]['child'] = db('kecheng_category')->field('id,name,pic')->where('aid',aid)->where('bid',$bid)->where('status',1)->where('pid',$v['id'])->order('sort desc,id')->select()->toArray();
}
if(getcustom('xixie')){
	//洗鞋分类
	$xixie_clist = db('xixie_category')->field('id,name,pic')->where('aid',aid)->where('status',1)->where('pid',0)->order('sort desc,id')->select()->toArray();
}
//周期购分类
$cycle_clist = db('cycle_category')->field('id,name,pic')->where('aid',aid)->where('status',1)->where('pid',0)->order('sort desc,id')->select()->toArray();
?>
<div class='panel-body flex' ng-app="FoxEditor" ng-controller="FoxController">
	<div class="dsn-phone">
		<div class="dsn-phone-left"></div>
		<div class="dsn-phone-center">
			<div class="dsn-phone-top"></div>
			<div class="dsn-phone-main">
				<div id="editor">
					<div ng-repeat="page in pages">
						<div ng-include="'show-'+page.temp+'.html'" id="{{page.id}}" mid="{{page.id}}" ng-click="setfocus(page.id,$event)"></div>
					</div>
					<div id="editor-content" style="background-color:{{pages[0].params.bgcolor}};">
						<div style="height: 50px;" ng-show="pages[0].params.guide==1"></div>

						<div ng-repeat="Item in Items" class="dsn-repeat" style="{{Item.temp=='cover'?'position:fixed;z-index:'+(9999+$index)+';top:'+(Item.params.top*5.6+contenttop)+'px;left:'+(Item.params.left*3.4+contentleft)+'px;':''}}" ng-mouseover="over(Item.id)" ng-mouseleave="out(Item.id)">
							<div ng-show="Item.temp!='cover'" class="dsn-mod-move" ng-mouseover="drag(Item.id)" ng-click="setfocus(Item.id,$event)"></div>
							<div ng-include="'show-'+Item.temp+'.html'" class="dsn-parent" id="{{Item.id}}" ng-show="Item" mid="{{Item.id}}" on-finish-render-filters></div>
							<div class="dsn-del" ng-click="delItem(Item.id)">移除</div>
						</div>
					</div>
				</div>
			</div>
			<div class="dsn-phone-bottom"></div>
		</div>
		<div class="dsn-phone-right"></div>
	</div>
	<div class="dsn-panel">
		<div class="dsn-panel-menu">
			<div ng-repeat="nav in navs">
				<nav ng-bind="nav.name" ng-click="addItem(nav.id)"></nav>
			</div>
		</div>
		<!-- editor start -->
		<div class="dsn-panel-editor" ng-show="focus" style="">
			<!-- <div class="dsn-panel-editor-ico"></div> -->
			<div ng-repeat="Edit in pages">
				<div ng-include="'edit-'+Edit.temp+'.html'" ng-show="focus==Edit.id" Editid="{{Edit.id}}" ></div>
			</div>
			<div ng-repeat="Edit in Items">
				<div ng-include="'edit-'+Edit.temp+'.html'" ng-show="focus==Edit.id" Editid="{{Edit.id}}" tab-index="-1"></div>
			</div>
		</div>
		<!-- editor end -->
	</div>

	<!-- editor template  page start -->
	{if $info['ishome']==2}
	<script type="text/ng-template" id="edit-topbar.html">{include file="designer_page/temp/edit-topbar2"}</script>
	{else}
	<script type="text/ng-template" id="edit-topbar.html">{include file="designer_page/temp/edit-topbar"}</script>
	{/if}
	<script type="text/ng-template" id="edit-shop.html">{include file="designer_page/temp/edit-shop"}</script>
	<script type="text/ng-template" id="edit-notice.html">{include file="designer_page/temp/edit-notice"}</script>
	<script type="text/ng-template" id="edit-menu.html">{include file="designer_page/temp/edit-menu"}</script>
	<script type="text/ng-template" id="edit-banner.html">{include file="designer_page/temp/edit-banner"}</script>
	<script type="text/ng-template" id="edit-picture.html">{include file="designer_page/temp/edit-picture"}</script>
	<script type="text/ng-template" id="edit-pictures.html">{include file="designer_page/temp/edit-pictures"}</script>
	<script type="text/ng-template" id="edit-title.html">{include file="designer_page/temp/edit-title"}</script>
	<script type="text/ng-template" id="edit-dhlist.html">{include file="designer_page/temp/edit-dhlist"}</script>
	<script type="text/ng-template" id="edit-text.html">{include file="designer_page/temp/edit-text"}</script>
	<script type="text/ng-template" id="edit-search.html">{include file="designer_page/temp/edit-search"}</script>
	<script type="text/ng-template" id="edit-lbssearch.html">{include file="designer_page/temp/edit-lbssearch"}</script>
	<script type="text/ng-template" id="edit-line.html">{include file="designer_page/temp/edit-line"}</script>
	<script type="text/ng-template" id="edit-blank.html">{include file="designer_page/temp/edit-blank"}</script>
	<script type="text/ng-template" id="edit-product.html">{include file="designer_page/temp/edit-product"}</script>
	<script type="text/ng-template" id="edit-cycle.html">{include file="designer_page/temp/edit-cycle"}</script>
	<script type="text/ng-template" id="edit-collage.html">{include file="designer_page/temp/edit-collage"}</script>
	<script type="text/ng-template" id="edit-kanjia.html">{include file="designer_page/temp/edit-kanjia"}</script>
	<script type="text/ng-template" id="edit-seckill.html">{include file="designer_page/temp/edit-seckill"}</script>
	<script type="text/ng-template" id="edit-scoreshop.html">{include file="designer_page/temp/edit-scoreshop"}</script>
	<script type="text/ng-template" id="edit-coupon.html">{include file="designer_page/temp/edit-coupon"}</script>
	<script type="text/ng-template" id="edit-richtext.html">{include file="designer_page/temp/edit-richtext"}</script>
	<script type="text/ng-template" id="edit-cube.html">{include file="designer_page/temp/edit-cube"}</script>
	<script type="text/ng-template" id="edit-video.html">{include file="designer_page/temp/edit-video"}</script>
	<script type="text/ng-template" id="edit-article.html">{include file="designer_page/temp/edit-article"}</script>
	<script type="text/ng-template" id="edit-form.html">{include file="designer_page/temp/edit-form"}</script>
	<script type="text/ng-template" id="edit-map.html">{include file="designer_page/temp/edit-map"}</script>
	<script type="text/ng-template" id="edit-button.html">{include file="designer_page/temp/edit-button"}</script>
	<script type="text/ng-template" id="edit-cover.html">{include file="designer_page/temp/edit-cover"}</script>
	<script type="text/ng-template" id="edit-business.html">{include file="designer_page/temp/edit-business"}</script>
	<script type="text/ng-template" id="edit-shortvideo.html">{include file="designer_page/temp/edit-shortvideo"}</script>
	<script type="text/ng-template" id="edit-liveroom.html">{include file="designer_page/temp/edit-liveroom"}</script>
	<script type="text/ng-template" id="edit-hotspot.html">{include file="designer_page/temp/edit-hotspot"}</script>
	<script type="text/ng-template" id="edit-userinfo.html">{include file="designer_page/temp/edit-userinfo"}</script>
	<script type="text/ng-template" id="edit-wxad.html">{include file="designer_page/temp/edit-wxad"}</script>
	<script type="text/ng-template" id="edit-jidian.html">{include file="designer_page/temp/edit-jidian"}</script>
	<script type="text/ng-template" id="edit-tab.html">{include file="designer_page/temp/edit-tab"}</script>
	<script type="text/ng-template" id="edit-kecheng.html">{include file="designer_page/temp/edit-kecheng"}</script>

	<script type="text/ng-template" id="edit-restaurant_product.html">{include file="designer_page/temp/edit-restaurant_product"}</script>
	<script type="text/ng-template" id="show-restaurant_product.html">{include file="designer_page/temp/show-restaurant_product"}</script>



	<script type="text/ng-template" id="edit-tuangou.html">{include file="designer_page/temp/edit-tuangou"}</script>

	<script type="text/ng-template" id="show-topbar.html">{include file="designer_page/temp/show-topbar"}</script>
	<script type="text/ng-template" id="show-shop.html">{include file="designer_page/temp/show-shop"}</script>
	<script type="text/ng-template" id="show-notice.html">{include file="designer_page/temp/show-notice"}</script>
	<script type="text/ng-template" id="show-menu.html">{include file="designer_page/temp/show-menu"}</script>
	<script type="text/ng-template" id="show-banner.html">{include file="designer_page/temp/show-banner"}</script>
	<script type="text/ng-template" id="show-picture.html">{include file="designer_page/temp/show-picture"}</script>
	<script type="text/ng-template" id="show-pictures.html">{include file="designer_page/temp/show-pictures"}</script>
	<script type="text/ng-template" id="show-title.html">{include file="designer_page/temp/show-title"}</script>
	<script type="text/ng-template" id="show-dhlist.html">{include file="designer_page/temp/show-dhlist"}</script>
	<script type="text/ng-template" id="show-text.html">{include file="designer_page/temp/show-text"}</script>
	<script type="text/ng-template" id="show-search.html">{include file="designer_page/temp/show-search"}</script>
	<script type="text/ng-template" id="show-lbssearch.html">{include file="designer_page/temp/show-lbssearch"}</script>
	<script type="text/ng-template" id="show-line.html">{include file="designer_page/temp/show-line"}</script>
	<script type="text/ng-template" id="show-blank.html">{include file="designer_page/temp/show-blank"}</script>
	<script type="text/ng-template" id="show-product.html">{include file="designer_page/temp/show-product"}</script>
	<script type="text/ng-template" id="show-cycle.html">{include file="designer_page/temp/show-cycle"}</script>
	<script type="text/ng-template" id="show-collage.html">{include file="designer_page/temp/show-collage"}</script>
	<script type="text/ng-template" id="show-kanjia.html">{include file="designer_page/temp/show-kanjia"}</script>
	<script type="text/ng-template" id="show-seckill.html">{include file="designer_page/temp/show-seckill"}</script>
	<script type="text/ng-template" id="show-scoreshop.html">{include file="designer_page/temp/show-scoreshop"}</script>
	<script type="text/ng-template" id="show-coupon.html">{include file="designer_page/temp/show-coupon"}</script>
	<script type="text/ng-template" id="show-richtext.html">{include file="designer_page/temp/show-richtext"}</script>
	<script type="text/ng-template" id="show-cube.html">{include file="designer_page/temp/show-cube"}</script>
	<script type="text/ng-template" id="show-video.html">{include file="designer_page/temp/show-video"}</script>
	<script type="text/ng-template" id="show-article.html">{include file="designer_page/temp/show-article"}</script>
	<script type="text/ng-template" id="show-form.html">{include file="designer_page/temp/show-form"}</script>
	<script type="text/ng-template" id="show-map.html">{include file="designer_page/temp/show-map"}</script>
	<script type="text/ng-template" id="show-button.html">{include file="designer_page/temp/show-button"}</script>
	<script type="text/ng-template" id="show-cover.html">{include file="designer_page/temp/show-cover"}</script>
	<script type="text/ng-template" id="show-business.html">{include file="designer_page/temp/show-business"}</script>
	<script type="text/ng-template" id="show-shortvideo.html">{include file="designer_page/temp/show-shortvideo"}</script>
	<script type="text/ng-template" id="show-liveroom.html">{include file="designer_page/temp/show-liveroom"}</script>
	<script type="text/ng-template" id="show-hotspot.html">{include file="designer_page/temp/show-hotspot"}</script>
	<script type="text/ng-template" id="show-userinfo.html">{include file="designer_page/temp/show-userinfo"}</script>
	<!--预约服务-->
	<script type="text/ng-template" id="edit-yuyue.html">{include file="designer_page/temp/edit-yuyue"}</script>
	<script type="text/ng-template" id="show-yuyue.html">{include file="designer_page/temp/show-yuyue"}</script>
	<script type="text/ng-template" id="show-tuangou.html">{include file="designer_page/temp/show-tuangou"}</script>
	<script type="text/ng-template" id="edit-luckycollage.html">{include file="designer_page/temp/edit-luckycollage"}</script>
	<script type="text/ng-template" id="show-luckycollage.html">{include file="designer_page/temp/show-luckycollage"}</script>

	<script type="text/ng-template" id="show-wxad.html">{include file="designer_page/temp/show-wxad"}</script>
	<script type="text/ng-template" id="show-jidian.html">{include file="designer_page/temp/show-jidian"}</script>
	<script type="text/ng-template" id="show-tab.html">{include file="designer_page/temp/show-tab"}</script>
	<script type="text/ng-template" id="show-kecheng.html">{include file="designer_page/temp/show-kecheng"}</script>
	<script type="text/ng-template" id="show-zhaopin.html">{include file="designer_page/temp/show-zhaopin"}</script>
	<script type="text/ng-template" id="edit-zhaopin.html">{include file="designer_page/temp/edit-zhaopin"}</script>
	<script type="text/ng-template" id="show-qiuzhi.html">{include file="designer_page/temp/show-qiuzhi"}</script>
	<script type="text/ng-template" id="edit-qiuzhi.html">{include file="designer_page/temp/edit-qiuzhi"}</script>
	<script type="text/ng-template" id="edit-form-log.html">{include file="designer_page/temp/edit-form-log"}</script>
	<script type="text/ng-template" id="show-form-log.html">{include file="designer_page/temp/show-form-log"}</script>

	
</div>

<script>var ngisfinish = 0;</script>
{include file="public/js"/}
<script type="text/javascript" src="{$Think.const.PRE_URL}/static/admin/js/bootstrap.min.js"></script>
<script type="text/javascript" src="{$Think.const.PRE_URL}/static/admin/js/angular.min.js"></script>
<script type="text/javascript" src="{$Think.const.PRE_URL}/static/admin/js/angular-ueditor.js?v=0329"></script>
<script type="text/javascript" src="{$Think.const.PRE_URL}/static/admin/js/hhSwipe.js"></script>
<script type="text/javascript" src="{$Think.const.PRE_URL}/static/admin/js/iconpicker.js"></script>
<script type="text/javascript" charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=ABLBZ-4BIKU-GFTVB-BK7IK-OLQ35-QCBFF"></script>

<script>
$( "#editor-content" ).sortable({ stop:function(event,ui){
		var $scope = angular.element(document.querySelector('[ng-controller=FoxController]')).scope();
		var arr = [];
		$(".dsn-repeat").find(".dsn-parent").each(function(i, val) {
			arr[i] = val.id;
		});
		var newarr = [];
		angular.forEach(arr, function(aid) {
			angular.forEach($scope.Items, function(obj) {
				if (obj.id == aid) {
					newarr.push(obj);
					return false;
				}
			});
		});
		console.log(newarr)
		$scope.Items = newarr;
		$scope.$apply();
	}})
function clone(myObj) {
	if (typeof(myObj) != 'object' || myObj == null) return myObj;
	var newObj = new Object();
	for (var i in myObj) {
		newObj[i] = clone(myObj[i]);
	}
	return newObj;
}
function cloneArr(arr) {
	var newArr = [];
	$(arr).each(function(i, val) {
		newArr.push(clone(val));
	});
	return newArr;
}

function initswipe(jobj) {
	var bullets = jobj.next().get(0).getElementsByTagName('a');
	var banner = Swipe(jobj.get(0), {
		auto: 2000,
		continuous: true,
		disableScroll: false,
		callback: function(pos) {
			var i = bullets.length;
			while (i--) {
				$(bullets[i]).css({'background-color':$(jobj.next()).attr('indicatorcolor'),'width':$(jobj.next()).attr('dotwidth')});
			}
			//console.log($(jobj.next()).attr('indicatorcolor'))
			//console.log($(jobj.next()).attr('indicatoractivecolor'))
			$(bullets[pos]).css({'background-color':$(jobj.next()).attr('indicatoractivecolor'),'width':$(jobj.next()).attr('dotactivewidth')});
		}
	})
}

function isUndefined(n) {
	return void 0 === n
}

var myModel = angular.module('FoxEditor', ['ng.ueditor']);
myModel.filter('price', function() {
    return function(text){
        return parseFloat(text).toString().split('.')[0];
    }
});
myModel.filter('price_dot', function() {
    return function(text){
        var pricearr = parseFloat(text).toString().split('.');
				if(pricearr[1]) return '.'+pricearr[1];
				else return '';
    }
});
myModel.controller('FoxController', ['$scope', function($scope) {
	$scope.navs = [
			{id:'notice',name:'公告',params:{showimg:0,img:'{$Think.const.PRE_URL}/static/imgsrc/hotdot3.png',showicon:1,icon:'{$Think.const.PRE_URL}/static/imgsrc/notice2.png',color:'#666666',bgcolor:'#ffffff',scroll:3,fontsize:'14',padding_x:'5',padding_y:'7',margin_x:'0',margin_y:'0',borderradius:0,quanxian:{'all':true},'platform':{'all':true}},
				data:[{id:'N001',title:'这里是第一条自定义公告的标题',hrefurl:''},{id:'N002',title:'这里是第二条自定义公告的标题',hrefurl:''}]
			},
			{id:'banner',name:'轮播图',params:{shape:'',align:'center',bgcolor:'#ffffff',margin_x:'0',margin_y:'0',padding_x:'0',padding_y:'0',height:'200',indicatordots:'1',indicatorcolor:'#edeef0',indicatoractivecolor:'#3db51e',interval:5,previous_margin:0,next_margin:0,quanxian:{'all':true},'platform':{'all':true}},
				 data:[
						 {id:'B0000000000001',imgurl:'{$Think.const.PRE_URL}/static/imgsrc/banner-1.jpg',hrefurl:''},
						 {id:'B0000000000002',imgurl:'{$Think.const.PRE_URL}/static/imgsrc/banner-2.jpg',hrefurl:''}
				 ]
			},
			{id:'shop',name:'店招',params:{style:'1',bgimg:'{$Think.const.PRE_URL}/static/imgsrc/banner-1.jpg',logo:'1',name:'1',menu:'1',navcolor:'#ffffff',bid:'{$bid}',quanxian:{'all':true},'platform':{'all':true}},
				 data:[
				 {id:'S001',text:'首页',imgurl:'{$Think.const.PRE_URL}/static/imgsrc/shop-home.png',color:'#fff',hrefurl:''},
				 {id:'S002',text:'全部商品',imgurl:'{$Think.const.PRE_URL}/static/imgsrc/shop-proall.png',color:'#fff',hrefurl:''},
				 {id:'S003',text:'促销商品',imgurl:'{$Think.const.PRE_URL}/static/imgsrc/shop-procx.png',color:'#fff',hrefurl:''},
				 {id:'S004',text:'店铺公告',imgurl:'{$Think.const.PRE_URL}/static/imgsrc/shop-notice.png',color:'#fff',hrefurl:''}]
			},
			{id:'search',name:'搜索框',params:{placeholder:'输入关键字搜索您感兴趣的商品','color':'#666666','bgcolor':'#F6F6F6',borderradius:5,'bordercolor':'#FFFFFF',hrefurl:'/pages/shop/search{$bid==0?'':'?bid='.$bid}',hrefname:'基础功能>商品搜索',margin_x:'0',margin_y:'0',padding_x:'6',padding_y:'6',quanxian:{'all':true},'platform':{'all':true},'openmore':false},
				data:[
						{id:'S001',title1:'列表1',title2:'输入搜索信息',hrefurl:''},
						{id:'S002',title1:'列表2',title2:'输入搜索信息',hrefurl:''},
						{id:'S003',title1:'列表3',title2:'输入搜索信息',hrefurl:''},
					]
			},
			
			{id:'picture',name:'单图',params:{bgcolor:'#FFFFFF',margin_x:'0',margin_y:'0',padding_x:'0',padding_y:'0',borderradius:'0',quanxian:{'all':true},'platform':{'all':true}},
				data:[{id:'P0000000000001',imgurl:'{$Think.const.PRE_URL}/static/imgsrc/banner-1.jpg',hrefurl:'',option:'0'}]
			},
			{id:'pictures',name:'多图',params:{style:'2',bgcolor:'#FFFFFF',margin_x:'0',margin_y:'0',padding_x:'0',padding_y:'0',quanxian:{'all':true},'platform':{'all':true}},
				data:[
					{id:'PS000000000001',imgurl:'{$Think.const.PRE_URL}/static/imgsrc/picture-1.jpg',hrefurl:'',option:'0'},
					{id:'PS000000000002',imgurl:'{$Think.const.PRE_URL}/static/imgsrc/picture-2.jpg',hrefurl:'',option:'0'},
					{id:'PS000000000003',imgurl:'{$Think.const.PRE_URL}/static/imgsrc/picture-3.jpg',hrefurl:'',option:'0'},
					{id:'PS000000000004',imgurl:'{$Think.const.PRE_URL}/static/imgsrc/picture-4.jpg',hrefurl:'',option:'0'}
				]
			},
			{id: "cube",name: "图片魔方",params: {bgcolor:'#FFFFFF',margin_x:'0',margin_y:'0',padding_x:'0',padding_y:'0',layout: {},showIndex: 0,selection: {},currentPos: {},currentLayout: {isempty: 1},quanxian:{'all':true},'platform':{'all':true}},data:[]},
			{id:'richtext',name:'富文本',params:{bgcolor:'#FFFFFF',margin_x:'0',margin_y:'0',padding_x:'10',padding_y:'10',quanxian:{'all':true},'platform':{'all':true}},content:''},
			{id:'video',name:'视频',params:{bgcolor:'#FFFFFF',margin_x:'0',margin_y:'0',padding_x:'0',padding_y:'0','pic':'','src':'http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400',quanxian:{'all':true},'platform':{'all':true}}},


			{id:'title',name:'标题',params:{bgcolor:'#F6F6F6',title:'猜你喜欢',fontsize:'14',color:'#333',showicon:1,iconsize:'14',imgurl:'{$Think.const.PRE_URL}/static/img/xihuan.png',linecolor:'#dddddd',margin_x:'0',margin_y:'0',padding_x:'30',padding_y:'5',quanxian:{'all':true},'platform':{'all':true}}},

			{id:'dhlist',name:'列表导航',params:{titlemarginleft:'8',bgcolor:'#ffffff',fontsize1:'16',fontsize2:'12',color1:'#333',color2:'#999',margin_x:'0',margin_y:'8',padding_x:'5',padding_y:'10',arrowshow:1,quanxian:{'all':true},'platform':{'all':true}},
				data:[
					{id:'D001',title1:'列表1',title2:'备注信息',showicon:1,iconcolor:'#CB5858',iconsize:'16',imgurl:'{$Think.const.PRE_URL}/static/img/xihuan.png'},
					{id:'D002',title1:'列表2',title2:'备注信息',showicon:1,iconcolor:'#CB5858',iconsize:'16',imgurl:'{$Think.const.PRE_URL}/static/img/xihuan.png'}
				]
			},

			{id:'text',name:'文本',params:{content:'文本内容',bgcolor:'#ffffff',fontsize:'14',lineheight:'20',letter_spacing:'0',bgpic:'',align:'left',color:'#000',margin_x:'0',margin_y:'0',padding_x:'5',padding_y:'5',quanxian:{'all':true},'platform':{'all':true},hrefurl:''}},

			{id:'button',name:'按钮',params:{bgcolor:'#ffffff',btntext:'按钮文字',btnbgcolor:'{:t('color1')}',btnbordercolor:'{:t('color1')}',btnfontsize:'14',btncolor:'#ffffff',btnwidth:'300',btnheight:'40',btnradius:'20',margin_x:'0',margin_y:'0',padding_x:'10',padding_y:'10',quanxian:{'all':true},'platform':{'all':true}},hrefurl:''},
			{id:'menu',name:'按钮导航',params:{num:'5',radius:'0',fontsize:'14',fontheight:'30',pernum:'10',bgcolor:'#ffffff',margin_x:'0',margin_y:'0',padding_x:'10',padding_y:'5',iconsize:'40',showicon:'1',showline:'0',showtitle:'0','title':'导航标题','titlesize':'16','titlecolor':'#333333','boxradius':'0',quanxian:{'all':true},'platform':{'all':true}},
					data:[
						{id:'F0000000000001',imgurl:'{$Think.const.PRE_URL}/static/imgsrc/picture-1.jpg',text:'按钮1',hrefurl:'',color:'#666666'},
						{id:'F0000000000002',imgurl:'{$Think.const.PRE_URL}/static/imgsrc/picture-2.jpg',text:'按钮2',hrefurl:'',color:'#666666'},
						{id:'F0000000000003',imgurl:'{$Think.const.PRE_URL}/static/imgsrc/picture-3.jpg',text:'按钮3',hrefurl:'',color:'#666666'},
						{id:'F0000000000004',imgurl:'{$Think.const.PRE_URL}/static/imgsrc/picture-4.jpg',text:'按钮4',hrefurl:'',color:'#666666'},
						{id:'F0000000000005',imgurl:'{$Think.const.PRE_URL}/static/imgsrc/picture-1.jpg',text:'按钮5',hrefurl:'',color:'#666666'}
					]
			},
			{id:'cover',name:'悬浮按钮',params:{style:'1',text:'咨询',fontsize:'14',bgcolor:'rgba(51, 136, 255, 0.7)',color:'#ffffff',border:0,bordercolor:'rgba(255, 255, 255, 0.7)',top:80,left:80,width:'50',height:'50',radius:'25',margin_x:'0',margin_y:'0',padding_x:'0',padding_y:'0',hrefurl:'/pages/kefu/index{$bid==0?'':'?bid='.$bid}',hrefname:'功能>在线客服',pic:'{$Think.const.PRE_URL}/static/img/zixun.png',picwidth:50,picheight:50,'alignstyle':'1',quanxian:{'all':true},'platform':{'all':true}}},
			{id:'line',name:'辅助线',params:{height:'2',style:'dashed',color:'#666666','bgcolor':'#F6F6F6',margin_x:'0',margin_y:'0',padding_x:'10',padding_y:'10',quanxian:{'all':true},'platform':{'all':true}}},
			{id:'blank',name:'辅助空白',params:{height:'50',bgcolor:'#F6F6F6',margin_x:'0',margin_y:'0',quanxian:{'all':true},'platform':{'all':true}}},

			{id:'tab',name:'选项卡',params:{bgcolor:'#F7F7F8',bgcolor2:'#FFFFFF',selectindex:0,fontsize1:'14',color1:'#333',color2:'{:t('color1')}',arrowshow:'1',arrowcolor:'{:t('color1')}',borderradius:'0',fixedtop:'0',margin_x:'0',margin_y:'0',padding_x:'0',padding_y:'0',quanxian:{'all':true},'platform':{'all':true}},data:[
				{id:'T0000000000001',name:'选项一',tabid:''},
				{id:'T0000000000002',name:'选项二',tabid:''},
				{id:'T0000000000003',name:'选项三',tabid:''}
			]},
			{id:'map',name:'地图',params:{height:'300','bgcolor':'#F6F6F6',address:'天安门广场',longitude:'116.397827',latitude:'39.90374',margin_x:'0',margin_y:'0',padding_x:'0',padding_y:'0',quanxian:{'all':true},'platform':{'all':true}}},

			{id:'hotspot',name:'热区',params:{bgcolor:'#FFFFFF',margin_x:'0',margin_y:'0',padding_x:'0',padding_y:'0',imgurl:'{$Think.const.PRE_URL}/static/imgsrc/banner-1.jpg',quanxian:{'all':true},'platform':{'all':true}},data:[
				{id:'H0000000000001',hrefurl:'',hrefname:'',left:'0',top:'0',width:'50',height:'50'}
			]},
			{if $auth_data=='all' || in_array('ShopProduct/*',$auth_data)}
			{id:'product',name:'商城商品',params:{style:'2',bgcolor:'#ffffff',probgcolor:'#ffffff',showname:'1',showcart:'1',cartimg:'{$Think.const.PRE_URL}/static/imgsrc/cart.svg',showprice:'1',showsales:'1',saleimg:'',showstock:'0',showbname:'0',showcoupon:'0',productfrom:'1',bid:'{$bid}',sortby:'sort',proshownum:6,margin_x:'0',margin_y:'0',padding_x:'8',padding_y:'8',group:{'all':true},quanxian:{'all':true},'platform':{'all':true}},data:[]},
			{/if}
			{if $auth_data=='all' || in_array('CollageProduct/*',$auth_data)}
			{id:'collage',name:'拼团商品',params:{style:'2',bgcolor:'#ffffff',showname:'1',showprice:'1',showsales:'1',saleimg:'',productfrom:'1',bid:'{$bid}',sortby:'sort',proshownum:6,shopstyle:1,margin_x:'0',margin_y:'0',padding_x:'8',padding_y:'8',quanxian:{'all':true},'platform':{'all':true}},data:[]},
			{/if}
			{if $auth_data=='all' || in_array('CycleProduct/*',$auth_data)}
		    {id:'cycle',name:'周期购商品',params:{style:'2',bgcolor:'#ffffff',showname:'1',showprice:'1',showsales:'1',saleimg:'',productfrom:'1',bid:'{$bid}',sortby:'sort',proshownum:6,margin_x:'0',margin_y:'0',padding_x:'8',padding_y:'8',quanxian:{'all':true},'platform':{'all':true}},data:[]},
			{/if}
			{if $auth_data=='all' || in_array('KanjiaProduct/*',$auth_data)}
			{id:'kanjia',name:'砍价商品',params:{style:'2',bgcolor:'#ffffff',showname:'1',showprice:'1',showsales:'1',saleimg:'',productfrom:'1',bid:'{$bid}',sortby:'sort',proshownum:6,margin_x:'0',margin_y:'0',padding_x:'8',padding_y:'8',quanxian:{'all':true},'platform':{'all':true}},data:[]},
			{/if}
			{if $auth_data=='all' || in_array('SeckillProduct/*',$auth_data)}
			{id:'seckill',name:'秒杀商品',params:{style:'2',bgcolor:'#ffffff',showname:'1',showprice:'1',showsales:'1',showtime:'0',saleimg:'',productfrom:'1',bid:'{$bid}',sortby:'sort',proshownum:6,shopstyle:1,showtitle:1,titlestyle:1,margin_x:'0',margin_y:'0',padding_x:'8',padding_y:'8',quanxian:{'all':true},'platform':{'all':true}},data:[]},
			{/if}
			{if $auth_data=='all' || in_array('TuangouProduct/*',$auth_data)}
			{id:'tuangou',name:'团购商品',params:{style:'2',bgcolor:'#ffffff',showname:'1',showcart:'1',cartimg:'{$Think.const.PRE_URL}/static/imgsrc/cart.svg',showprice:'1',showsales:'1',saleimg:'',productfrom:'1',bid:'{$bid}',sortby:'sort',proshownum:6,margin_x:'0',margin_y:'0',padding_x:'8',padding_y:'8',quanxian:{'all':true},'platform':{'all':true}},data:[]},
			{/if}
			{if $auth_data=='all' || in_array('LuckyCollageProduct/*',$auth_data)}
			{id:'luckycollage',name:'幸运拼团',params:{style:'2',bgcolor:'#ffffff',showname:'1',showcart:'1',cartimg:'{$Think.const.PRE_URL}/static/imgsrc/cart.svg',showprice:'1',showsales:'1',saleimg:'',productfrom:'1',bid:'{$bid}',sortby:'sort',proshownum:6,margin_x:'0',margin_y:'0',padding_x:'8',padding_y:'8',quanxian:{'all':true},'platform':{'all':true}},data:[]},
			{/if}
			{if $auth_data=='all' || in_array('Restaurant/*',$auth_data)}
			{id:'restaurant_product',name:'餐饮菜品',params:{style:'2',bgcolor:'#ffffff',showname:'1',showcart:'0',showtype:'0',cartimg:'{$Think.const.PRE_URL}/static/imgsrc/cart.svg',showprice:'1',showsales:'1',saleimg:'',productfrom:'1',bid:'{$bid}',sortby:'sort',proshownum:6,margin_x:'0',margin_y:'0',padding_x:'8',padding_y:'8',quanxian:{'all':true},'platform':{'all':true}},data:[]},
			{/if}
			{if $bid==0 && ($auth_data=='all' || in_array('ScoreshopProduct/*',$auth_data))}
			{id:'scoreshop',name:'{:t('积分')}兑换',params:{style:'2',bgcolor:'#ffffff',showname:'1',showprice:'1',showsales:'1',saleimg:'',productfrom:'1',sortby:'sort',proshownum:6,margin_x:'0',margin_y:'0',padding_x:'8',padding_y:'8',quanxian:{'all':true},'platform':{'all':true}},data:[]},
			{/if}
			{if $auth_data=='all' || in_array('Coupon/*',$auth_data)}
			{id:'coupon',name:'{:t('优惠券')}',params:{style:'1',titlecolor:'#fff',remarkcolor:'#e5e5e5',bgcolor:'#FFF',bgpic:'{$Think.const.PRE_URL}/static/imgsrc/coupon1.png',couponfrom:'1',sortby:'sort',bid:'{$bid}',shownum:6,margin_x:'0',margin_y:'0',padding_x:'0',padding_y:'4',quanxian:{'all':true},'platform':{'all':true}},data:[]},
			{/if}
			{if $auth_data=='all' || in_array('Article/*',$auth_data)}
			{id:'article',name:'文章列表',params:{style:'4',showpic:'1',articlefrom:'1',bid:'{$bid}',sortby:'sort',shownum:6,showtime:'1',showreadcount:'1',margin_x:'0',margin_y:'0',padding_x:'5',padding_y:'5',quanxian:{'all':true},'platform':{'all':true}},data:[]},
			{/if}
			{if $auth_data=='all' || in_array('Form/*',$auth_data)}
			{id:'form',name:'表单',params:{style:'1',fontsize:'14',color:'#000000',showmuststar:true,inputbordercolor:'#eeeeee',inputbgcolor:'#ffffff','linecolor':'#ede4e4',bgcolor:'#ffffff',btntext:'提 交',btnbgcolor:'{:t('color1')}',btnbordercolor:'{:t('color1')}',btnfontsize:'14',btncolor:'#ffffff',btnwidth:'300',btnheight:'40',btnradius:'20',margin_x:'0',margin_y:'0',padding_x:'10',padding_y:'10',hrefurl:'/pages/form/formlog',hrefname:'基础功能>提交记录','isquery':'0',quanxian:{'all':true},'platform':{'all':true}},data:[]},
			
			{/if}
			{if $auth_data=='all' || in_array('Shortvideo/*',$auth_data)}
			{id:'shortvideo',name:'短视频',params:{bgcolor:'#ffffff',showlogo:'1',showviewnum:'1',showzannum:'1',productfrom:'1',bid:'{$bid}',sortby:'sort',shownum:6,margin_x:'0',margin_y:'0',padding_x:'8',padding_y:'8',category:'',quanxian:{'all':true},'platform':{'all':true}},data:[]},
			{/if}
			{if $bid==0 && in_array('wx',$platform) && ($auth_data=='all' || in_array('Live/*',$auth_data))}
			{id:'liveroom',name:'直播列表',params:{titlecolor:'#333',bgcolor:'#F6F6F6',liveroomfrom:'1',sortby:'sort',shownum:12,margin_x:'0',margin_y:'0',padding_x:'6',padding_y:'6',quanxian:{'all':true},'platform':{'all':true}},data:[]},
			{/if}
			{if $bid==0 && ($auth_data=='all' || in_array('Business/*',$auth_data))}
			{id:'business',name:'商家',params:{titlecolor:'#333',bgcolor:'#F6F6F6',businessfrom:'1',showpingfen:'1',showsales:'1',showaddress:'1',showjianjie:'0',showdistance:'0','showproduct':'0',distance:'30',sortby:'sort',shownum:6,margin_x:'0',margin_y:'0',padding_x:'0',padding_y:'0',quanxian:{'all':true},'platform':{'all':true}},data:[]},
			{/if}
			{if $auth_data=='all' || in_array('YuyueList/*',$auth_data)}
			{id:'yuyue',name:'预约服务',params:{style:'2',bgcolor:'#ffffff',showname:'1',showcart:'1',showprice:'1',showsales:'1',saleimg:'',productfrom:'1',bid:'{$bid}',sortby:'sort',proshownum:6,margin_x:'0',margin_y:'0',padding_x:'8',padding_y:'8',group:{'all':true},quanxian:{'all':true},'platform':{'all':true}},data:[]},
			{/if}
			{if $auth_data=='all' || in_array('KechengList/*',$auth_data)}
			{id:'kecheng',name:'课程列表',params:{style:'2',bgcolor:'#F7F7F8',showname:'1',showcart:'1',showprice:'1',showsales:'1',saleimg:'',productfrom:'1',bid:'{$bid}',sortby:'sort',proshownum:6,margin_x:'0',margin_y:'0',padding_x:'8',padding_y:'8',group:{'all':true},quanxian:{'all':true},'platform':{'all':true}},data:[]},
			{/if}
			
			{if in_array('wx',$platform)}
			{id:'wxad',name:'小程序广告',params:{adtype:'banner',unitid:'',bgcolor:'#ffffff',margin_x:'0',margin_y:'0',padding_x:'8',padding_y:'8',quanxian:{'all':true},'platform':{"all":false,"wx":true}},data:[]},
			{/if}
			
			{id:'userinfo',name:'{:t('会员')}信息',params:{moneyshow:'1',scoreshow:'1',couponshow:'1',seticonshow:'1',cardshow:'0',levelshow:'1',levelclick:'1',ordershow:'1',commissionshow:'1',midshow:'0',bgimg:'{$Think.const.PRE_URL}/static/imgsrc/userinfobg.png',style:'2',margin_x:'0',margin_y:'0',padding_x:'10',padding_y:'10',quanxian:{'all':true},'platform':{'all':true}}},
			
	];
	{php}
	if($bid==0){
		$sysset = db('admin_set')->field('name,logo')->where('aid',aid)->find();
	}else{
		$sysset = db('business')->field('name,logo')->where('id',$bid)->find();
	}
	{/php}
	$scope.pages = {$pageinfo};
	$scope.system = { name: "{$sysset['name']}",logo: "{$sysset['logo']}"};
	$scope.Items = {$pagedata}; //初始数据
	$scope.focus = $scope.pages[0].id;
	$scope.contenttop = 0;
	$scope.contentleft = 0;
	$scope.hasCube = function(Item) {
		var has = false;
		var row = 0,col = 0;
		for(var i = row; i < 4; i++) {
			for(var j = col; j < 4; j++) {
				if(!isUndefined(Item.params.layout[i][j]) && !Item.params.layout[i][j].isempty) {
					has = true;
					break;
				}
			}
		}
		return has;
	}
	$scope.showSelection = function(Edit, row, col){
		Edit.params.currentPos = {row: row,col: col};
		Edit.params.selection = {};
		var maxrow = 4,maxcol = 4,end = false;
		for(var i = row; i <= 3; i++) {
			if(isUndefined(Edit.params.layout[i][col]) || !isUndefined(Edit.params.layout[i][col]) && !Edit.params.layout[i][col].isempty) {
				maxrow = i;
				end = true;
			}
			if (end) {break;}
		}
		end = false;
		for(var j = col; j <= 3; j++) {
			if(isUndefined(Edit.params.layout[row][j]) || !isUndefined(Edit.params.layout[row][j]) && !Edit.params.layout[row][j].isempty) {
				maxcol = j;
				end = true;
			}
			if(end) {break;}
		}
		var f = maxcol,n=-1,g = 1;
		for(var i = row; i < maxrow; i++) {
			var y = 1;
			Edit.params.selection[g] = {};
			for(var j = col; j < maxcol; j++) {
				if(f>j && (!isUndefined(Edit.params.layout[i][j]) && Edit.params.layout[i][j].isempty)) {
					Edit.params.selection[g][y] = {rows: g,cols: y};
					y++;
				}else if(f > j){
					f = j
				}
			}
			g++;
		}
		//console.log(Edit.params.selection)

		$(".layout-table li").removeClass("selected");
		//$scope.modalobj = $("#" + Edit.id + "-modal-cube-layout").modal({show: true});
		$scope.modalobj = layer.open({type:1,content:$("#" + Edit.id + "-modal-cube-layout"),area:['400px','400px'],title:'选择布局',shadeClose:true})
		$('#' + Edit.id + '-modal-cube-layout').find(".layout-table").unbind('mouseover').mouseover(function(a) {
			if ("LI" == a.target.tagName) {
				$(".layout-table li").removeClass("selected");
				var c = $(a.target).attr("data-rows"),d = $(a.target).attr("data-cols");
				$(".layout-table li").filter(function(a, e) {
					return $(e).attr("data-rows") <= c && $(e).attr("data-cols") <= d
				}).addClass("selected")
			}
		});
		return true;
	}
	$scope.selectLayout = function(Edit, currentRow, currentCol, rows, cols) {
		if (isUndefined(rows)) {rows = 0;}
		if (isUndefined(cols)) {cols = 0;}
		Edit.params.layout[currentRow][currentCol] = {
			cols: cols,
			rows: rows,
			isempty: false,
			imgurl: "",
			classname: "index-" + Edit.params.showIndex
		};
		for (var i = parseInt(currentRow); i < parseInt(currentRow) + parseInt(rows); i++) {
			for (var j = parseInt(currentCol); j < parseInt(currentCol) + parseInt(cols); j++) {
				if (currentRow != i || currentCol != j) {
					delete Edit.params.layout[i][j];
				}
			}
		}
		Edit.params.showIndex++;
		layer.close($scope.modalobj);

		var maxheight = 0;
		for(var i in Edit.params.layout){
			for(var j in Edit.params.layout[i]){
				var col = Edit.params.layout[i][j];
				if(!isUndefined(col['rows']) && !col['isempty'] && parseInt(i) + parseInt(col['rows']) > maxheight){
					maxheight = parseInt(i) + parseInt(col['rows']);
				}
			}
		}
		console.log(maxheight)
		Edit.params.maxheight = maxheight;


		$scope.changeItem(Edit, currentRow, currentCol);

		return true;
	}
	$scope.changeItem = function(Edit, row, col) {
		$("#cube-editor td").removeClass("current").filter(function(a, e) {
			return $(e).attr("x") == row && $(e).attr("y") == col
		}).addClass("current");
		$("#cube_thumb").attr("src", "");
		Edit.params.currentLayout = Edit.params.layout[row][col];
	}
	$scope.delCube = function(Edit, Cid, cols, rows) {
		if (Edit && Cid && cols && rows) {
			var len = Edit.params.layout.length;
			$.each(Edit.params.layout, function(row, a) {
				$.each(Edit.params.layout[row], function(col, b) {
					if (col != '$$hashKey') {
						if (b.classname == Edit.params.currentLayout.classname) {
							row = parseInt(row);
							col = parseInt(col);
							rows = parseInt(rows);
							cols = parseInt(cols);
							for (var i = row; i < row + rows; i++) {
								for (var j = col; j < col + cols; j++) {
									Edit.params.layout[i][j] = {
										cols: 1,
										rows: 1,
										isempty: true,
										imgurl: "",
										classname: ""
									};
								}
							}
						}
					}
				});
			});
		}
	}
	// 1.1 添加一条子级(good,picture,banner,dhlist,search)
	$scope.addItemChild = function(type, Mid) {
		if (type && Mid) {
			t = '';
			if (type == 'good') {
				t = 'G';
			} else if (type == 'picture') {
				t = 'P';
			} else if (type == 'pictures') {
				t = 'PS';
			} else if (type == 'banner') {
				t = 'B';
			} else if (type == 'dhlist') {
				t = 'D';
			} else if (type == 'menu') {
				t = 'M';
			} else if (type == 'spot') {
				t = 'H';
			} else if (type == 'tab') {
				t = 'T';
			} else if (type == 'search') {
				t = 'S';
			}
			var var_id = t + new Date().getTime() + parseInt(Math.random() * 1000000);
			var push = {
				banner: {
					id: var_id,
					imgurl: '{$Think.const.PRE_URL}/static/imgsrc/banner-2.jpg',
					hrefurl: ''
				},
				picture: {
					id: var_id,
					imgurl: '{$Think.const.PRE_URL}/static/imgsrc/banner-2.jpg',
					hrefurl: ''
				},
				pictures: {
					id: var_id,
					imgurl: '{$Think.const.PRE_URL}/static/imgsrc/picture-1.jpg',
					hrefurl: ''
				},
				good: {},
				dhlist: {id:var_id,title1:'列表名称',title2:'备注信息',showicon:1,icon:'fa fa-heart',iconcolor:'#333',iconsize:'16',imgurl:''},
				notice2: {id:var_id,title:'这里是一条自定义公告的标题',hrefurl:''},
				menu: {id:var_id,imgurl:'{$Think.const.PRE_URL}/static/imgsrc/picture-1.jpg',text:'按钮文字',hrefurl:'',color:'#666666'},
				spot: {id:var_id,width:'50',height:'50',left:0,top:0,hrefurl:'',hrefname:''},
				tab: {id:var_id,name:'选项X',tabid:''},
				search: {id:var_id,title1:'列表名称',title2:'输入搜索信息'},
			};
			var Items = $scope.Items;
			angular.forEach(Items, function(m, index) {
				if (m.id == Mid) {
					if(!m.data){
						m.data = [];
					}
					m.data.push(push[type]);
				}
			});
		}
	}

	// 1.1 删除一条子级
	$scope.delItemChild = function(Mid, Cid) {
		var Items = $scope.Items;
		angular.forEach(Items, function(m, index1) {
			if (m.id == Mid) {
				angular.forEach(m.data, function(c, index2) {
					if (c.id == Cid) {
						m.data.splice(index2, 1);
					}
				});
			}
		});
	}
	//上移子级
	$scope.upItemChild = function(Mid, Cid) {
		var Items = $scope.Items;
		angular.forEach(Items, function(m, index1) {
			if (m.id == Mid) {
				angular.forEach(m.data, function(c, index2) {
					if (c.id == Cid) {
						if(index2 == 0){
							layer.msg('已经到顶了');
							return;
						}
						m.data[index2] = m.data.splice(index2-1, 1, m.data[index2])[0];
					}
				});
			}
		});
	}

	$scope.iconImg = function(Mid){
			fileUploader.show(function(data){
				 var Items = $scope.Items;
				 angular.forEach(Items, function(m,index1) {
						 if(m.id==Mid){
								 m.params.icon = data['url'];
								 $("div[mid="+Mid+"]").mouseover();
						 }
				 });
			}, {type :'image',tabs:{selecticon:'active',upload: '',browser:''}});
	}
	$scope.selecticon = function(Mid,paramsName){
		iconpicker.show(function(data) {
			console.log(data)
			var Items = $scope.Items;
			angular.forEach(Items, function(m, index1) {
				if(m.id == Mid){
					m.params[paramsName] = data;
					$("div[mid=" + Mid + "]").mouseover();
					$scope.$apply();
				}
			});
		})
	}
	$scope.selecticon2 = function(Mid,Cid,paramsName){
		iconpicker.show(function(data) {
			var Items = $scope.Items;
			angular.forEach(Items, function(m, index1) {
				if(m.id == Mid){
					angular.forEach(m.data, function(c, index2) {
						if(c.id == Cid) {
							c[paramsName] = data;
							$("div[mid=" + Mid + "]").mouseover();
							$scope.$apply();
						}
					});
				}
			});
		})
	}
	// 1.1 上传图片
	$scope.uploadImg = function(Mid,paramsName) {
		fileUploader.show(function(data) {
			if(Mid == 'M0000000000000' || Mid == 'M0000000000001' || Mid == 'M0000000000002'){
				$scope.pages[0].params[paramsName] = data['url'];
				$scope.$apply();
				return;
			}
			var Items = $scope.Items;
			angular.forEach(Items, function(m, index1) {
				if(m.id == Mid){
					m.params[paramsName] = data['url'];
					$("div[mid=" + Mid + "]").mouseover();
				}
			});
		}, {type: 'image'});
	}
	$scope.uploadImgChild = function(Mid, Cid, Type) {
		fileUploader.show(function(data) {
			var Items = $scope.Items;
			angular.forEach(Items, function(m, index1) {
				if(m.id == Mid){
					if(Type == 'cube'){
						m.params.currentLayout.imgurl = data['url'];
						$("div[mid=" + Mid + "]").mouseover();
					}else{
						angular.forEach(m.data, function(c, index2) {
							if(c.id == Cid) {
								c.imgurl = data['url'];
								$("div[mid=" + Mid + "]").mouseover();
							}
						});
					}
				}
			});
		}, {type: 'image'});
	}

	$scope.chooseUrlCube = function(Mid, Cid) {
		var Items = $scope.Items;
		angular.forEach(Items, function(m) {
			if(m.id == Mid) {
				m.params.currentLayout.url = 'http://www.qq.com';
				$("div[mid=" + Mid + "]").mouseover();
			}
		});
	}

	$scope.designerTab = function(Mid, Cid,tabname) {
		console.log(Mid);
		console.log(Cid);
		var designerTabLayer = layer.open({type:2,shadeClose: false,area: ['94%', '94%'],'title': '设置选项卡内容',content:"{:url('DesignerPage/designer_tab')}&tabid="+Mid+"&tabindexid="+Cid+'&tabname='+tabname,btn:['确定','取消'],yes:function(index, layero){
			var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象
			var tabpagedata = iframeWin.geteditordata();
			layer.close(designerTabLayer);
			var index = layer.load();
			$.post("{:url('DesignerPage/designer_tab_save')}",{tabid:Mid,tabindexid:Cid,tabpagedata:tabpagedata},function(data){
				layer.close(index);
			})
		}})
	}
	//地图 选择坐标
	$scope.choosezuobiao = function(Mid,address,jd,wd){
		var choosezblayer = layer.open({type:2,shadeClose: true,area: ['800px', '560px'],'title': '选择坐标',content: "{:url('DesignerPage/choosezuobiao')}/Mid/"+Mid+'&address='+(address?address:'')+'&jd='+(jd?jd:'')+'&wd='+(wd?wd:''),btn:['确定','取消'],yes:function(index, layero){
			var longitude = layero.find('iframe').contents().find('#mapjd').val();
			var latitude = layero.find('iframe').contents().find('#mapwd').val();
			angular.forEach($scope.Items, function(m, index1) {
				if(m.id == Mid){
					m.params.longitude = longitude;
					m.params.latitude = latitude;
					var center = new qq.maps.LatLng(latitude,longitude);
					var map = new qq.maps.Map(document.getElementById("showmp_"+Mid), {
						center: center,      // 地图的中心地理坐标。
						zoom:15              // 地图的中心地理坐标。
					});
					var marker = new qq.maps.Marker({ position:center, map: map});

					$("div[mid=" + Mid + "]").mouseover();
				}
			});
			layer.close(choosezblayer);
		}});
	}
	// 1.1 选择链接
	$scope.chooseUrl = function(Mid, Cid) {
		layer.open({type:2,shadeClose: true,area: ['1100px', '650px'],'title': '选择链接',content: "{:url('DesignerPage/chooseurl')}/fromdsn/1/args/"+Mid+','+Cid})
	}
	$scope.chooseLink = function(urlname,url,args) {
		var argsArr = args.split(',');
		var Mid = argsArr[0];
		var Cid = argsArr[1];
		if (url && Mid && Cid){
			if(Mid == 'M0000000000000' || Mid == 'M0000000000001' || Mid == 'M0000000000002'){
				if(Cid == -2){
					$scope.pages[0].params['hrefurl2'] = url;
				}else{
					$scope.pages[0].params['hrefurl'] = url;
				}
				$scope.$apply();
				return;
			}
			angular.forEach($scope.Items, function(m, index1) {
				if(m.id == Mid){
					if(m.temp == 'cube'){
						m.params.currentLayout.hrefurl = url;
						m.params.currentLayout.hrefname = urlname;
						$("div[mid=" + Mid + "]").mouseover();
					}else{
						if(Cid == -1){
							m.params.hrefurl = url;
							m.params.hrefname = urlname
						}else if(Cid == -2){
							m.params.hrefurl2 = url;
							m.params.hrefname2 = urlname
						}else{
							angular.forEach(m.data, function(c, index2) {
								if(c.id == Cid) {
									c.hrefurl = url;
									console.log(c.hrefurl)
									c.hrefname = urlname
								}
							});
						}
					}
				}
			});
			layer.closeAll();
		}
	}
	$scope.temp = {notcie: []};
	//商城商品
	$scope.getgoods = function(Mid) {
		angular.forEach($scope.Items, function(m, index1) {
			if (m.id == Mid) {
				var bid = m.params.bid
				console.log(bid)
				var category = m.params.category
				var category2 = m.params.category2
				var group = m.params.group
				var sortby = m.params.sortby
				var proshownum = m.params.proshownum
				$.ajax({
					type: 'post',
					dataType: 'json',
					url: "{:url('DesignerPage/api')}/op/selectproduct",
					data: {
						bid: bid,
						cid: category,
						cid2: category2,
						giddata: group,
						sortby: sortby,
						proshownum: proshownum
					},
					success: function(data) {
						m.data = [];
						angular.forEach(data, function(d, i) {
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							// 执行添加
							m.data.push({
								id: Gid,
								pic: data[i].pic,
								proid: data[i].id,
								name: data[i].name,
								market_price: data[i].market_price,
								sell_price: data[i].sell_price,
								sales: data[i].sales,
								merchant_name: data[i].merchant_name? data[i].merchant_name:'',
								main_business: data[i].main_business?data[i].main_business:''
							});
						});
						$("div[mid=" + Mid + "]").mouseover();
					},
					error: function() {
						layer.msg('查询商品信息失败！请刷新页面。');
					}
				});
			}
		});
	}
	$scope.addGood = function(action, Mid, Gid) {
		layer.open({type:2,shadeClose:true,area:['920px', '560px'],'title':'选择商品',content:"{:url('ShopProduct/chooseproduct')}/args/"+action+','+Mid+','+Gid});
	}
	$scope.delGood = function(Mid, Gid) {
		var Items = $scope.Items;
		angular.forEach(Items, function(m, index1) {
			if (m.id == Mid) {
				angular.forEach(m.data, function(g, index2) {
					if (g.id == Gid) {
						m.data.splice(index2, 1);
					}
				});
			}
		});
	}
	$scope.pushGood = function(prodata,args){
		var argsArr = args.split(',');
		var action = argsArr[0];
		var Mid = argsArr[1];
		var oldGid = argsArr[2];
		angular.forEach($scope.Items, function(m, index1) {
			if(m.id == Mid){
				if(action == 'replace' && oldGid){
					// 执行替换
					angular.forEach(m.data, function(r, index3){
						if(r.id == oldGid){
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							r.id = Gid;
							r.pic = prodata.pic;
							r.proid = prodata.id;
							r.name = prodata.name;
							r.market_price = prodata.market_price;
							r.sell_price = prodata.sell_price;
							r.sales = prodata.sales;
						}
					});
				}else if(!action){
					var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
					// 执行添加
					m.data.push({
						id: Gid,
						pic: prodata.pic,
						proid: prodata.id,
						name: prodata.name,
						market_price: prodata.market_price,
						sell_price: prodata.sell_price,
						sales: prodata.sales
					});
				}
			}
		});
	}
	//餐饮商品
	$scope.getRestaurantGoods = function(Mid) {
		angular.forEach($scope.Items, function(m, index1) {
			if (m.id == Mid) {
				var bid = m.params.bid
				console.log(bid)
				var category = m.params.category
				var group = m.params.group
				var sortby = m.params.sortby
				var proshownum = m.params.proshownum
				$.ajax({
					type: 'post',
					dataType: 'json',
					url: "{:url('DesignerPage/api')}/op/selectRestaurantproduct",
					data: {
						bid: bid,
						cid: category,
						giddata: group,
						sortby: sortby,
						proshownum: proshownum
					},
					success: function(data) {
						m.data = [];
						angular.forEach(data, function(d, i) {
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							// 执行添加
							m.data.push({
								id: Gid,
								pic: data[i].pic,
								proid: data[i].id,
								name: data[i].name,
								market_price: data[i].market_price,
								sell_price: data[i].sell_price,
								sales: data[i].sales
							});
						});
						$("div[mid=" + Mid + "]").mouseover();
					},
					error: function() {
						layer.msg('查询菜品信息失败！请刷新页面。');
					}
				});
			}
		});
	}
	$scope.addRestaurantGood = function(action, Mid, Gid) {
		layer.open({type:2,shadeClose:true,area:['920px', '560px'],'title':'选择菜品',content:"{:url('RestaurantProduct/chooseproduct')}/args/"+action+','+Mid+','+Gid});
	}
	$scope.delRestaurantGood = function(Mid, Gid) {
		var Items = $scope.Items;
		angular.forEach(Items, function(m, index1) {
			if (m.id == Mid) {
				angular.forEach(m.data, function(g, index2) {
					if (g.id == Gid) {
						m.data.splice(index2, 1);
					}
				});
			}
		});
	}
	//拼团商品
	$scope.getcollage = function(Mid) {
		angular.forEach($scope.Items, function(m, index1) {
			if (m.id == Mid) {
				var bid = m.params.bid
				var category = m.params.category
				var sortby = m.params.sortby
				var proshownum = m.params.proshownum
				$.ajax({
					type: 'post',
					dataType: 'json',
					url: "{:url('DesignerPage/api')}/op/selectcollage",
					data: {
						bid: bid,
						cid: category,
						sortby: sortby,
						proshownum: proshownum
					},
					success: function(data) {
						m.data = [];
						angular.forEach(data, function(d, i) {
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							// 执行添加
							m.data.push({
								id: Gid,
								pic: data[i].pic,
								proid: data[i].id,
								name: data[i].name,
								market_price: data[i].market_price,
								sell_price: data[i].sell_price,
								sales: data[i].sales,
								teamnum: data[i].teamnum
							});
						});
						$("div[mid=" + Mid + "]").mouseover();
					},
					error: function() {
						layer.msg('查询商品信息失败！请刷新页面。');
					}
				});
			}
		});
	}
	$scope.addcollage = function(action, Mid, Gid) {
		layer.open({type:2,shadeClose:true,area:['920px', '560px'],'title':'选择商品',content:"{:url('CollageProduct/chooseproduct')}/args/"+action+','+Mid+','+Gid});
	}
	$scope.delcollage = function(Mid, Gid) {
		var Items = $scope.Items;
		angular.forEach(Items, function(m, index1) {
			if (m.id == Mid) {
				angular.forEach(m.data, function(g, index2) {
					if (g.id == Gid) {
						m.data.splice(index2, 1);
					}
				});
			}
		});
	}
	$scope.pushcollage = function(prodata,args){
		var argsArr = args.split(',');
		var action = argsArr[0];
		var Mid = argsArr[1];
		var oldGid = argsArr[2];
		angular.forEach($scope.Items, function(m, index1) {
			if(m.id == Mid){
				if(action == 'replace' && oldGid){
					// 执行替换
					angular.forEach(m.data, function(r, index3){
						if(r.id == oldGid){
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							r.id = Gid;
							r.pic = prodata.pic;
							r.proid = prodata.id;
							r.name = prodata.name;
							r.market_price = prodata.market_price;
							r.sell_price = prodata.sell_price;
							r.sales = prodata.sales;
						}
					});
				}else if(!action){
					var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
					// 执行添加
					m.data.push({
						id: Gid,
						pic: prodata.pic,
						proid: prodata.id,
						name: prodata.name,
						market_price: prodata.market_price,
						sell_price: prodata.sell_price,
						sales: prodata.sales
					});
				}
			}
		});
	}

	//周期购
	$scope.getcycle = function(Mid) {
			angular.forEach($scope.Items, function(m, index1) {
				if (m.id == Mid) {
					var bid = m.params.bid
					var category = m.params.category
					var sortby = m.params.sortby
					var proshownum = m.params.proshownum
					$.ajax({
						type: 'post',
						dataType: 'json',
						url: "{:url('DesignerPage/api')}/op/selectcycle",
						data: {
							bid: bid,
							cid: category,
							sortby: sortby,
							proshownum: proshownum
						},
						success: function(data) {
							m.data = [];
							angular.forEach(data, function(d, i) {
								var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
								// 执行添加
								m.data.push({
									id: Gid,
									pic: data[i].pic,
									proid: data[i].id,
									name: data[i].name,
									market_price: data[i].market_price,
									sell_price: data[i].sell_price,
									sales: data[i].sales,
									pspl: data[i].pspl,
								});
							});
							$("div[mid=" + Mid + "]").mouseover();
						},
						error: function() {
							layer.msg('查询商品信息失败！请刷新页面。');
						}
					});
				}
			});
		}
	$scope.addcycle = function(action, Mid, Gid) {
			layer.open({type:2,shadeClose:true,area:['920px', '560px'],'title':'选择商品',content:"{:url('CycleProduct/chooseproduct')}/args/"+action+','+Mid+','+Gid});
		}
	$scope.delcycle = function(Mid, Gid) {
			var Items = $scope.Items;
			angular.forEach(Items, function(m, index1) {
				if (m.id == Mid) {
					angular.forEach(m.data, function(g, index2) {
						if (g.id == Gid) {
							m.data.splice(index2, 1);
						}
					});
				}
			});
		}
	$scope.pushcycle = function(prodata,args){
			var argsArr = args.split(',');
			var action = argsArr[0];
			var Mid = argsArr[1];
			var oldGid = argsArr[2];
			angular.forEach($scope.Items, function(m, index1) {
				if(m.id == Mid){
					if(action == 'replace' && oldGid){
						// 执行替换
						angular.forEach(m.data, function(r, index3){
							if(r.id == oldGid){
								var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
								r.id = Gid;
								r.pic = prodata.pic;
								r.proid = prodata.id;
								r.name = prodata.name;
								r.market_price = prodata.market_price;
								r.sell_price = prodata.sell_price;
								r.sales = prodata.sales;
								r.pspl = prodata.pspl;
							}
						});
					}else if(!action){
						var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
						// 执行添加
						m.data.push({
							id: Gid,
							pic: prodata.pic,
							proid: prodata.id,
							name: prodata.name,
							market_price: prodata.market_price,
							sell_price: prodata.sell_price,
							sales: prodata.sales,
							pspl: prodata.pspl,
						});
					}
				}
			});
		}
	//幸运拼团商品
	$scope.getluckycollage = function(Mid) {
		angular.forEach($scope.Items, function(m, index1) {
			if (m.id == Mid) {
				var bid = m.params.bid
				var category = m.params.category
				var sortby = m.params.sortby
				var proshownum = m.params.proshownum
				$.ajax({
					type: 'post',
					dataType: 'json',
					url: "{:url('DesignerPage/api')}/op/selectluckycollage",
					data: {
						bid: bid,
						cid: category,
						sortby: sortby,
						proshownum: proshownum
					},
					success: function(data) {
						m.data = [];
						angular.forEach(data, function(d, i) {
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							// 执行添加
							m.data.push({
								id: Gid,
								pic: data[i].pic,
								proid: data[i].id,
								name: data[i].name,
								market_price: data[i].market_price,
								sell_price: data[i].sell_price,
								sales: data[i].sales,
								teamnum: data[i].teamnum,
								money:data[i].money,
								gua_num:data[i].gua_num
							});
						});
						$("div[mid=" + Mid + "]").mouseover();
					},
					error: function() {
						layer.msg('查询商品信息失败！请刷新页面。');
					}
				});
			}
		});
	}
	$scope.addluckycollage = function(action, Mid, Gid) {
		layer.open({type:2,shadeClose:true,area:['920px', '560px'],'title':'选择商品',content:"{:url('LuckyCollageProduct/chooseproduct')}/args/"+action+','+Mid+','+Gid});
	}
	$scope.delluckycollage = function(Mid, Gid) {
		var Items = $scope.Items;
		angular.forEach(Items, function(m, index1) {
			if (m.id == Mid) {
				angular.forEach(m.data, function(g, index2) {
					if (g.id == Gid) {
						m.data.splice(index2, 1);
					}
				});
			}
		});
	}
	$scope.pushluckycollage = function(prodata,args){
		//console.log(prodata);
		var argsArr = args.split(',');
		var action = argsArr[0];
		var Mid = argsArr[1];
		var oldGid = argsArr[2];
		angular.forEach($scope.Items, function(m, index1) {
			if(m.id == Mid){
				if(action == 'replace' && oldGid){
					// 执行替换
					angular.forEach(m.data, function(r, index3){
						if(r.id == oldGid){
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							r.id = Gid;
							r.pic = prodata.pic;
							r.proid = prodata.id;
							r.name = prodata.name;
							r.market_price = prodata.market_price;
							r.sell_price = prodata.sell_price;
							r.sales = prodata.sales;
							r.teamnum = prodata.teamnum;
							r.gua_num=prodata.gua_num;
							r.money=prodata.money
						}
					});
				}else if(!action){
					var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
					// 执行添加
					m.data.push({
						id: Gid,
						pic: prodata.pic,
						proid: prodata.id,
						name: prodata.name,
						market_price: prodata.market_price,
						sell_price: prodata.sell_price,
						sales: prodata.sales,
						teamnum:prodata.teamnum,
						gua_num:prodata.gua_num,
						money:prodata.money,
					});
				}
			}
		});
	}

	//砍价商品
	$scope.getkanjia = function(Mid) {
		angular.forEach($scope.Items, function(m, index1) {
			if (m.id == Mid) {
				var bid = m.params.bid
				var sortby = m.params.sortby
				var proshownum = m.params.proshownum
				$.ajax({
					type: 'post',
					dataType: 'json',
					url: "{:url('DesignerPage/api')}/op/selectkanjia",
					data: {
						bid: bid,
						sortby: sortby,
						proshownum: proshownum
					},
					success: function(data) {
						m.data = [];
						angular.forEach(data, function(d, i) {
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							// 执行添加
							m.data.push({
								id: Gid,
								pic: data[i].pic,
								proid: data[i].id,
								name: data[i].name,
								min_price: data[i].min_price,
								sell_price: data[i].sell_price,
								sales: data[i].sales
							});
						});
						$("div[mid=" + Mid + "]").mouseover();
					},
					error: function() {
						layer.msg('查询商品信息失败！请刷新页面。');
					}
				});
			}
		});
	}
	$scope.addkanjia = function(action, Mid, Gid) {
		layer.open({type:2,shadeClose:true,area:['920px', '560px'],'title':'选择商品',content:"{:url('KanjiaProduct/chooseproduct')}/args/"+action+','+Mid+','+Gid});
	}
	$scope.delkanjia = function(Mid, Gid) {
		var Items = $scope.Items;
		angular.forEach(Items, function(m, index1) {
			if (m.id == Mid) {
				angular.forEach(m.data, function(g, index2) {
					if (g.id == Gid) {
						m.data.splice(index2, 1);
					}
				});
			}
		});
	}
	$scope.pushkanjia = function(prodata,args){
		var argsArr = args.split(',');
		var action = argsArr[0];
		var Mid = argsArr[1];
		var oldGid = argsArr[2];
		angular.forEach($scope.Items, function(m, index1) {
			if(m.id == Mid){
				if(action == 'replace' && oldGid){
					// 执行替换
					angular.forEach(m.data, function(r, index3){
						if(r.id == oldGid){
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							r.id = Gid;
							r.pic = prodata.pic;
							r.proid = prodata.id;
							r.name = prodata.name;
							r.min_price = prodata.min_price;
							r.sell_price = prodata.sell_price;
							r.sales = prodata.sales;
						}
					});
				}else if(!action){
					var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
					// 执行添加
					m.data.push({
						id: Gid,
						pic: prodata.pic,
						proid: prodata.id,
						name: prodata.name,
						min_price: prodata.min_price,
						sell_price: prodata.sell_price,
						sales: prodata.sales
					});
				}
			}
		});
	}
	//秒杀商品
	$scope.getseckill = function(Mid) {
		angular.forEach($scope.Items, function(m, index1) {
			if (m.id == Mid) {
				var bid = m.params.bid
				var sortby = m.params.sortby
				var proshownum = m.params.proshownum
				$.ajax({
					type: 'post',
					dataType: 'json',
					url: "{:url('DesignerPage/api')}/op/selectseckill",
					data: {
						bid: bid,
						sortby: sortby,
						proshownum: proshownum
					},
					success: function(data) {
						m.data = [];
						angular.forEach(data, function(d, i) {
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							// 执行添加
							m.data.push({
								id: Gid,
								pic: data[i].pic,
								proid: data[i].id,
								name: data[i].name,
								market_price: data[i].market_price,
								sell_price: data[i].sell_price,
								sales: data[i].sales
							});
						});
						$("div[mid=" + Mid + "]").mouseover();
					},
					error: function() {
						layer.msg('查询商品信息失败！请刷新页面。');
					}
				});
			}
		});
	}
	$scope.addseckill = function(action, Mid, Gid) {
		layer.open({type:2,shadeClose:true,area:['920px', '560px'],'title':'选择商品',content:"{:url('SeckillProduct/chooseproduct')}/args/"+action+','+Mid+','+Gid});
	}
	$scope.delseckill = function(Mid, Gid) {
		var Items = $scope.Items;
		angular.forEach(Items, function(m, index1) {
			if (m.id == Mid) {
				angular.forEach(m.data, function(g, index2) {
					if (g.id == Gid) {
						m.data.splice(index2, 1);
					}
				});
			}
		});
	}
	$scope.pushseckill = function(prodata,args){
		var argsArr = args.split(',');
		var action = argsArr[0];
		var Mid = argsArr[1];
		var oldGid = argsArr[2];
		angular.forEach($scope.Items, function(m, index1) {
			if(m.id == Mid){
				if(action == 'replace' && oldGid){
					// 执行替换
					angular.forEach(m.data, function(r, index3){
						if(r.id == oldGid){
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							r.id = Gid;
							r.pic = prodata.pic;
							r.proid = prodata.id;
							r.name = prodata.name;
							r.market_price = prodata.market_price;
							r.sell_price = prodata.sell_price;
							r.sales = prodata.sales;
						}
					});
				}else if(!action){
					var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
					// 执行添加
					m.data.push({
						id: Gid,
						pic: prodata.pic,
						proid: prodata.id,
						name: prodata.name,
						market_price: prodata.market_price,
						sell_price: prodata.sell_price,
						sales: prodata.sales
					});
				}
			}
		});
	}

	//积分兑换商品
	$scope.getscoreshop = function(Mid) {
		angular.forEach($scope.Items, function(m, index1) {
			if (m.id == Mid) {
				var category = m.params.category
				var sortby = m.params.sortby
				var proshownum = m.params.proshownum
				$.ajax({
					type: 'post',
					dataType: 'json',
					url: "{:url('DesignerPage/api')}/op/selectscoreshop",
					data: {
						cid: category,
						sortby: sortby,
						proshownum: proshownum
					},
					success: function(data) {
						m.data = [];
						angular.forEach(data, function(d, i) {
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							// 执行添加
							m.data.push({
								id: Gid,
								pic: data[i].pic,
								proid: data[i].id,
								name: data[i].name,
								sell_price: data[i].sell_price,
								money_price: data[i].money_price,
								score_price: data[i].score_price,
								sales: data[i].sales
							});
						});
						$("div[mid=" + Mid + "]").mouseover();
					},
					error: function() {
						layer.msg('查询商品信息失败！请刷新页面。');
					}
				});
			}
		});
	}
	$scope.addscoreshop = function(action, Mid, Gid) {
		layer.open({type:2,shadeClose:true,area:['920px', '560px'],'title':'选择商品',content:"{:url('ScoreshopProduct/chooseproduct')}/args/"+action+','+Mid+','+Gid});
	}
	$scope.delscoreshop = function(Mid, Gid) {
		var Items = $scope.Items;
		angular.forEach(Items, function(m, index1) {
			if (m.id == Mid) {
				angular.forEach(m.data, function(g, index2) {
					if (g.id == Gid) {
						m.data.splice(index2, 1);
					}
				});
			}
		});
	}
	$scope.pushscoreshop = function(prodata,args){
		var argsArr = args.split(',');
		var action = argsArr[0];
		var Mid = argsArr[1];
		var oldGid = argsArr[2];
		angular.forEach($scope.Items, function(m, index1) {
			if(m.id == Mid){
				if(action == 'replace' && oldGid){
					// 执行替换
					angular.forEach(m.data, function(r, index3){
						if(r.id == oldGid){
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							r.id = Gid;
							r.pic = prodata.pic;
							r.proid = prodata.id;
							r.name = prodata.name;
							r.sell_price = prodata.sell_price;
							r.score_price = prodata.score_price;
							r.money_price = prodata.money_price;
							r.sales = prodata.sales;
						}
					});
				}else if(!action){
					var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
					// 执行添加
					m.data.push({
						id: Gid,
						pic: prodata.pic,
						proid: prodata.id,
						name: prodata.name,
						sell_price: prodata.sell_price,
						score_price: prodata.score_price,
						money_price: prodata.money_price,
						sales: prodata.sales
					});
				}
			}
		});
	}

	//团购商品
	$scope.gettuangou = function(Mid) {
		angular.forEach($scope.Items, function(m, index1) {
			if (m.id == Mid) {
				var bid = m.params.bid
				console.log(bid)
				var category = m.params.category
				var group = m.params.group
				var sortby = m.params.sortby
				var proshownum = m.params.proshownum
				$.ajax({
					type: 'post',
					dataType: 'json',
					url: "{:url('DesignerPage/api')}/op/selecttuangou",
					data: {
						bid: bid,
						cid: category,
						sortby: sortby,
						proshownum: proshownum
					},
					success: function(data) {
						m.data = [];
						angular.forEach(data, function(d, i) {
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							// 执行添加
							m.data.push({
								id: Gid,
								pic: data[i].pic,
								proid: data[i].id,
								name: data[i].name,
								market_price: data[i].market_price,
								sell_price: data[i].sell_price,
								min_price: data[i].min_price,
								sales: data[i].sales
							});
						});
						$("div[mid=" + Mid + "]").mouseover();
					},
					error: function() {
						layer.msg('查询商品信息失败！请刷新页面。');
					}
				});
			}
		});
	}
	$scope.addTuangou = function(action, Mid, Gid) {
		layer.open({type:2,shadeClose:true,area:['920px', '560px'],'title':'选择商品',content:"{:url('TuangouProduct/chooseproduct')}/args/"+action+','+Mid+','+Gid});
	}
	$scope.delTuangou = function(Mid, Gid) {
		var Items = $scope.Items;
		angular.forEach(Items, function(m, index1) {
			if (m.id == Mid) {
				angular.forEach(m.data, function(g, index2) {
					if (g.id == Gid) {
						m.data.splice(index2, 1);
					}
				});
			}
		});
	}
	$scope.pushTuangou = function(prodata,args){
		console.log(prodata)
		var argsArr = args.split(',');
		var action = argsArr[0];
		var Mid = argsArr[1];
		var oldGid = argsArr[2];
		angular.forEach($scope.Items, function(m, index1) {
			if(m.id == Mid){
				if(action == 'replace' && oldGid){
					// 执行替换
					angular.forEach(m.data, function(r, index3){
						if(r.id == oldGid){
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							r.id = Gid;
							r.pic = prodata.pic;
							r.proid = prodata.id;
							r.name = prodata.name;
							r.market_price = prodata.market_price;
							r.sell_price = prodata.sell_price;
							r.min_price = prodata.min_price;
							r.sales = prodata.sales;
						}
					});
				}else if(!action){
					var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
					// 执行添加
					m.data.push({
						id: Gid,
						pic: prodata.pic,
						proid: prodata.id,
						name: prodata.name,
						market_price: prodata.market_price,
						sell_price: prodata.sell_price,
						min_price: prodata.min_price,
						sales: prodata.sales
					});
				}
			}
		});
	}
	//课程商品
	$scope.getKecheng = function(Mid) {
		angular.forEach($scope.Items, function(m, index1) {
			if (m.id == Mid) {
				var bid = m.params.bid
				console.log(bid)
				var category = m.params.category
				var sortby = m.params.sortby
				var proshownum = m.params.proshownum
				$.ajax({
					type: 'post',
					dataType: 'json',
					url: "{:url('DesignerPage/api')}/op/selectkecheng",
					data: {
						bid: bid,
						cid: category,
						sortby: sortby,
						proshownum: proshownum
					},
					success: function(data) {
						m.data = [];
						angular.forEach(data, function(d, i) {
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							// 执行添加
							m.data.push({
								id: Gid,
								pic: data[i].pic,
								proid: data[i].id,
								name: data[i].name,
								market_price: data[i].market_price,
								price: data[i].price,
								join_num: data[i].join_num,
								count: data[i].count,
							});
						});
						$("div[mid=" + Mid + "]").mouseover();
					},
					error: function() {
						layer.msg('查询商品信息失败！请刷新页面。');
					}
				});
			}
		});
	}
	$scope.addKecheng = function(action, Mid, Gid) {
		layer.open({type:2,shadeClose:true,area:['920px', '560px'],'title':'选择课程',content:"{:url('KechengList/chooseproduct')}/args/"+action+','+Mid+','+Gid});
	}
	$scope.delKecheng = function(Mid, Gid) {
		var Items = $scope.Items;
		angular.forEach(Items, function(m, index1) {
			if (m.id == Mid) {
				angular.forEach(m.data, function(g, index2) {
					if (g.id == Gid) {
						m.data.splice(index2, 1);
					}
				});
			}
		});
	}
	$scope.pushKecheng = function(prodata,args){
		var argsArr = args.split(',');
		var action = argsArr[0];
		var Mid = argsArr[1];
		var oldGid = argsArr[2];
		angular.forEach($scope.Items, function(m, index1) {
			if(m.id == Mid){
				if(action == 'replace' && oldGid){
					// 执行替换
					angular.forEach(m.data, function(r, index3){
						if(r.id == oldGid){
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							r.id = Gid;
							r.pic = prodata.pic;
							r.proid = prodata.id;
							r.name = prodata.name;
							r.market_price = prodata.market_price;
							r.price = prodata.price;
							r.join_num = prodata.join_num;
							r.count = prodata.count;
						}
					});
				}else if(!action){
					var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
					// 执行添加
					m.data.push({
						id: Gid,
						pic: prodata.pic,
						proid: prodata.id,
						name: prodata.name,
						market_price: prodata.market_price,
						price: prodata.price,
						join_num: prodata.join_num,
						count: prodata.count
					});
				}
			}
		});
	}


		//zhaopin
		$scope.getZhaopin = function(Mid) {
			angular.forEach($scope.Items, function(m, index1) {
				if (m.id == Mid) {
					var bid = m.params.bid
					console.log('--------------ddddd------------------------')
					console.log(m.data)
					console.log('---------------dddd-----------------------')
					var sortby = m.params.sortby
					var shownum = m.params.shownum
					$.ajax({
						type: 'post',
						dataType: 'json',
						url: "{:url('DesignerPage/api')}/op/selectzhaopin",
						data: {
							bid: bid,
							sortby: sortby,
							shownum: shownum
						},
						success: function(data) {

							console.log('--------------------------------------')
							console.log(data)
							console.log('--------------------------------------')
							m.data = [];
							angular.forEach(data, function(d, i) {
								var Gid = 'Z' + new Date().getTime() + parseInt(Math.random() * 1000000);
								// 执行添加
								m.data.push({
									id: Gid,
									thumb: data[i].thumb,
									proid: data[i].id,
									title: data[i].title,
									area: data[i].area,
									salary: data[i].salary,
									num: data[i].num,
								});
							});
							$("div[mid=" + Mid + "]").mouseover();
						},
						error: function() {
							layer.msg('查询信息失败！请刷新页面。');
						}
					});
				}
			});
		}
		$scope.addZhaopin = function(action, Mid, Gid) {
			layer.open({type:2,shadeClose:true,area:['920px', '560px'],'title':'选择招聘',content:"{:url('Zhaopin/choosezhaopin')}/args/"+action+','+Mid+','+Gid});
		}
		$scope.delZhaopin = function(Mid, Gid) {
			var Items = $scope.Items;
			angular.forEach(Items, function(m, index1) {
				if (m.id == Mid) {
					angular.forEach(m.data, function(g, index2) {
						if (g.id == Gid) {
							m.data.splice(index2, 1);
						}
					});
				}
			});
		}
		$scope.pushZhaopin = function(prodata,args){
			var argsArr = args.split(',');
			var action = argsArr[0];
			var Mid = argsArr[1];
			var oldGid = argsArr[2];
			angular.forEach($scope.Items, function(m, index1) {
				if(m.id == Mid){
					if(action == 'replace' && oldGid){
						// 执行替换
						angular.forEach(m.data, function(r, index3){
							if(r.id == oldGid){
								var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
								r.id = Gid;
								r.thumb = prodata.thumb;
								r.proid = prodata.id;
								r.title = prodata.title;
								r.salary = prodata.salary;
								r.area = prodata.area
								r.count = prodata.count;
							}
						});
					}else if(!action){
						var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
						// 执行添加
						m.data.push({
							id: Gid,
							thumb: prodata.thumb,
							proid: prodata.id,
							title: prodata.title,
							salary: prodata.salary,
							area: prodata.area,
							num: prodata.num
						});
					}
				}
			});
		}
		//zhaopin end

		//qiuzhi
		$scope.getQiuzhi = function(Mid) {
			angular.forEach($scope.Items, function(m, index1) {
				if (m.id == Mid) {
					var bid = m.params.bid
					console.log(bid)
					var sortby = m.params.sortby
					var shownum = m.params.shownum
					$.ajax({
						type: 'post',
						dataType: 'json',
						url: "{:url('DesignerPage/api')}/op/selectqiuzhi",
						data: {
							bid: bid,
							sortby: sortby,
							shownum: shownum
						},
						success: function(data) {
							m.data = [];
							angular.forEach(data, function(d, i) {
								var Gid = 'Q' + new Date().getTime() + parseInt(Math.random() * 1000000);
								// 执行添加
								m.data.push({
									id: Gid,
									thumb: data[i].thumb,
									proid: data[i].id,
									title: data[i].title,
									name: data[i].name,
									cnames: data[i].names,
									age: data[i].age,
									sex: data[i].sex,
									has_job: data[i].has_job,
									area: data[i].area,
									salary: data[i].salary,
									secret_type:data[i].secret_type,
									mohu:data[i].mohu
								});
							});
							$("div[mid=" + Mid + "]").mouseover();
						},
						error: function() {
							layer.msg('查询信息失败！请刷新页面。');
						}
					});
				}
			});
		}
		$scope.addQiuzhi = function(action, Mid, Gid) {
			layer.open({type:2,shadeClose:true,area:['920px', '560px'],'title':'选择求职',content:"{:url('ZhaopinQiuzhi/chooseqiuzhi')}/args/"+action+','+Mid+','+Gid});
		}
		$scope.delQiuzhi = function(Mid, Gid) {
			var Items = $scope.Items;
			angular.forEach(Items, function(m, index1) {
				if (m.id == Mid) {
					angular.forEach(m.data, function(g, index2) {
						if (g.id == Gid) {
							m.data.splice(index2, 1);
						}
					});
				}
			});
		}
		$scope.pushQiuzhi = function(prodata,args){
			var argsArr = args.split(',');
			var action = argsArr[0];
			var Mid = argsArr[1];
			var oldGid = argsArr[2];
			angular.forEach($scope.Items, function(m, index1) {
				if(m.id == Mid){
					if(action == 'replace' && oldGid){
						// 执行替换
						angular.forEach(m.data, function(r, index3){
							if(r.id == oldGid){
								var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
								r.id = Gid;
								r.thumb = prodata.thumb;
								r.proid = prodata.id;
								r.title = prodata.title;
								r.name = prodata.name;
								r.cnames = prodata.cnames;
								r.age = prodata.age;
								r.sex = prodata.sex;
								r.has_job = prodata.has_job;
								r.salary = prodata.salary;
								r.area = prodata.area;
								r.secret_type = prodata.secret_type;
								r.mohu = prodata.mohu;
							}
						});
					}else if(!action){
						var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
						// 执行添加
						m.data.push({
							id: Gid,
							thumb: prodata.thumb,
							proid: prodata.id,
							name: prodata.name,
							cnames: prodata.cnames,
							title: prodata.title,
							age:prodata.age,
							sex:prodata.sex,
							has_job:prodata.has_job,
							salary: prodata.salary,
							area: prodata.area,
							secret_type:prodata.secret_type,
							mohu:prodata.mohu
						});
					}
				}
			});
		}
		//zhaopin end

	//商家
	$scope.getbusiness = function(Mid) {
		angular.forEach($scope.Items, function(m, index1) {
			if (m.id == Mid) {
				var category = m.params.category
				var sortby = m.params.sortby
				var shownum = m.params.shownum
				$.ajax({
					type: 'post',
					dataType: 'json',
					url: "{:url('DesignerPage/api')}/op/selectbusiness",
					data: {
						cid: category,
						sortby: sortby,
						shownum: shownum
					},
					success: function(data) {
						m.data = [];
						angular.forEach(data, function(d, i) {
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							// 执行添加
							m.data.push({
								id: Gid,
								logo: data[i].logo,
								bid: data[i].id,
								name: data[i].name,
								address: data[i].address,
								sales: data[i].sales,
								content: data[i].content,
								comment_score: data[i].comment_score,
								commentscore: Math.floor(data[i].comment_score),
								prolist: data[i].prolist
							});
						});
						$("div[mid=" + Mid + "]").mouseover();
					},
					error: function() {
						layer.msg('查询商品信息失败！请刷新页面。');
					}
				});
			}
		});
	}
	$scope.addbusiness = function(action, Mid, Gid) {
		layer.open({type:2,shadeClose:true,area:['920px', '560px'],'title':'选择商品',content:"{:url('Business/choosebusiness')}/args/"+action+','+Mid+','+Gid});
	}
	$scope.delbusiness = function(Mid, Gid) {
		var Items = $scope.Items;
		angular.forEach(Items, function(m, index1) {
			if (m.id == Mid) {
				angular.forEach(m.data, function(g, index2) {
					if (g.id == Gid) {
						m.data.splice(index2, 1);
					}
				});
			}
		});
	}
	$scope.pushbusiness = function(prodata,args){
		var argsArr = args.split(',');
		var action = argsArr[0];
		var Mid = argsArr[1];
		var oldGid = argsArr[2];
		angular.forEach($scope.Items, function(m, index1) {
			if(m.id == Mid){
				if(action == 'replace' && oldGid){
					// 执行替换
					angular.forEach(m.data, function(r, index3){
						if(r.id == oldGid){
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							r.id = Gid;
							r.logo = prodata.logo;
							r.bid = prodata.id;
							r.name = prodata.name;
							r.comment_score = prodata.comment_score;
							r.commentscore = Math.floor(prodata.comment_score);
							r.address = prodata.address;
							r.sales = prodata.sales;
							r.content = prodata.content;
							r.prolist = prodata.prolist;
						}
					});
				}else if(!action){
					var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
					// 执行添加
					m.data.push({
						id: Gid,
						logo: prodata.logo,
						bid: prodata.id,
						name: prodata.name,
						comment_score: prodata.comment_score,
						commentscore: Math.floor(prodata.comment_score),
						address: prodata.address,
						sales: prodata.sales,
						content: prodata.content,
						prolist: prodata.prolist
					});
				}
			}
		});
	}

	//短视频
	$scope.getshortvideo = function(Mid) {
		angular.forEach($scope.Items, function(m, index1) {
			if (m.id == Mid) {
				var bid = m.params.bid
				var cid = m.params.category
				var sortby = m.params.sortby
				var shownum = m.params.shownum
				$.ajax({
					type: 'post',
					dataType: 'json',
					url: "{:url('DesignerPage/api')}/op/selectshortvideo",
					data: {
						bid: bid,
						cid: cid,
						sortby: sortby,
						shownum: shownum
					},
					success: function(data) {
						m.data = [];
						angular.forEach(data, function(d, i) {
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							// 执行添加
							m.data.push({
								id: Gid,
								videoId: data[i].videoId,
								logo: data[i].logo,
								name: data[i].name,
								description: data[i].description,
								coverimg: data[i].coverimg,
								view_num: data[i].view_num,
								zan_num: data[i].zan_num
							});
						});
						$("div[mid=" + Mid + "]").mouseover();
					},
					error: function() {
						layer.msg('查询信息失败！请刷新页面。');
					}
				});
			}
		});
	}
	$scope.addshortvideo = function(action, Mid, Gid) {
		layer.open({type:2,shadeClose:true,area:['920px', '560px'],'title':'选择短视频',content:"{:url('Shortvideo/choosevideo')}/args/"+action+','+Mid+','+Gid});
	}
	$scope.delshortvideo = function(Mid, Gid) {
		var Items = $scope.Items;
		angular.forEach(Items, function(m, index1) {
			if (m.id == Mid) {
				angular.forEach(m.data, function(g, index2) {
					if (g.id == Gid) {
						m.data.splice(index2, 1);
					}
				});
			}
		});
	}
	$scope.pushshortvideo = function(prodata,args){
		var argsArr = args.split(',');
		var action = argsArr[0];
		var Mid = argsArr[1];
		var oldGid = argsArr[2];
		angular.forEach($scope.Items, function(m, index1) {
			if(m.id == Mid){
				if(action == 'replace' && oldGid){
					// 执行替换
					angular.forEach(m.data, function(r, index3){
						if(r.id == oldGid){
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							r.id = Gid;
							r.videoId = prodata.id;
							r.logo = prodata.logo;
							r.name = prodata.name;
							r.description = prodata.description;
							r.coverimg = prodata.coverimg;
							r.view_num = prodata.view_num;
							r.zan_num = prodata.zan_num;
						}
					});
				}else if(!action){
					var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
					// 执行添加
					m.data.push({
						id: Gid,
						videoId: prodata.id,
						logo: prodata.logo,
						name: prodata.name,
						description: prodata.description,
						coverimg: prodata.coverimg,
						view_num: prodata.view_num,
						zan_num: prodata.zan_num
					});
				}
			}
		});
	}
	//直播间
	$scope.getliveroom = function(Mid) {
		angular.forEach($scope.Items, function(m, index1) {
			if (m.id == Mid) {
				var sortby = m.params.sortby
				var shownum = m.params.shownum
				$.ajax({
					type: 'post',
					dataType: 'json',
					url: "{:url('DesignerPage/api')}/op/selectliveroom",
					data: {
						sortby: sortby,
						shownum: shownum
					},
					success: function(data) {
						m.data = [];
						angular.forEach(data, function(d, i) {
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							// 执行添加
							m.data.push({
								id: Gid,
								roomId: data[i].roomId,
								bid: data[i].bid,
								name: data[i].name,
								coverImg: data[i].coverImg,
								shareImg: data[i].shareImg,
								anchorName: data[i].anchorName,
								startTime: data[i].startTime,
								endTime: data[i].endTime,
								showtime: data[i].showtime,
								status: data[i].status
							});
						});
						$("div[mid=" + Mid + "]").mouseover();
					},
					error: function() {
						layer.msg('查询信息失败！请刷新页面。');
					}
				});
			}
		});
	}
	$scope.addliveroom = function(action, Mid, Gid) {
		layer.open({type:2,shadeClose:true,area:['920px', '560px'],'title':'选择直播间',content:"{:url('Live/chooseliveroom')}/args/"+action+','+Mid+','+Gid});
	}
	$scope.delliveroom = function(Mid, Gid) {
		var Items = $scope.Items;
		angular.forEach(Items, function(m, index1) {
			if (m.id == Mid) {
				angular.forEach(m.data, function(g, index2) {
					if (g.id == Gid) {
						m.data.splice(index2, 1);
					}
				});
			}
		});
	}
	$scope.pushliveroom = function(prodata,args){
		var argsArr = args.split(',');
		var action = argsArr[0];
		var Mid = argsArr[1];
		var oldGid = argsArr[2];
		angular.forEach($scope.Items, function(m, index1) {
			if(m.id == Mid){
				if(action == 'replace' && oldGid){
					// 执行替换
					angular.forEach(m.data, function(r, index3){
						if(r.id == oldGid){
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							r.id = Gid;
							r.roomId = prodata.roomId;
							r.bid = prodata.bid;
							r.name = prodata.name;
							r.coverImg = prodata.coverImg;
							r.shareImg = prodata.shareImg;
							r.anchorName = prodata.anchorName;
							r.startTime = prodata.startTime;
							r.endTime = prodata.endTime;
							r.showtime = prodata.showtime;
							r.status = prodata.status;
						}
					});
				}else if(!action){
					var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
					// 执行添加
					m.data.push({
						id: Gid,
						roomId: prodata.roomId,
						bid: prodata.bid,
						name: prodata.name,
						coverImg: prodata.coverImg,
						shareImg: prodata.shareImg,
						startTime: prodata.startTime,
						endTime: prodata.endTime,
						showtime: prodata.showtime,
						status: prodata.status
					});
				}
			}
		});
	}


	$scope.getarticle = function(Mid) {
		angular.forEach($scope.Items, function(m, index1) {
			if (m.id == Mid) {
				var bid = m.params.bid
				var category = m.params.category
				var sortby = m.params.sortby
				var shownum = m.params.shownum
				$.ajax({
					type: 'post',
					dataType: 'json',
					url: "{:url('DesignerPage/api')}/op/selectarticle",
					data: {
						bid: bid,
						cid: category,
						sortby: sortby,
						shownum: shownum
					},
					success: function(data) {
						m.data = [];
						angular.forEach(data, function(d, i) {
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							// 执行添加
							m.data.push({
								id: Gid,
								pic: data[i].pic,
								artid: data[i].id,
								name: data[i].name,
								subname: data[i].subname,
								readcount: data[i].readcount,
								createtime: date('Y-m-d H:i',data[i].createtime)
							});
						});
						$("div[mid=" + Mid + "]").mouseover();
					},
					error: function() {
						layer.msg('查询信息失败！请刷新页面。');
					}
				});
			}
		});
	}
	$scope.addArticle = function(action, Mid, Gid) {
		layer.open({type:2,shadeClose:true,area:['920px', '560px'],'title':'选择文章',content:"{:url('Article/choosearticle')}/args/"+action+','+Mid+','+Gid});
	}
	$scope.delArticle = function(Mid, Gid) {
		var Items = $scope.Items;
		angular.forEach(Items, function(m, index1) {
			if (m.id == Mid) {
				angular.forEach(m.data, function(g, index2) {
					if (g.id == Gid) {
						m.data.splice(index2, 1);
					}
				});
			}
		});
	}
	$scope.pushArticle = function(artdata,args){
		var argsArr = args.split(',');
		var action = argsArr[0];
		var Mid = argsArr[1];
		var oldGid = argsArr[2];
		angular.forEach($scope.Items, function(m, index1) {
			if(m.id == Mid){
				if(action == 'replace' && oldGid){
					console.log(oldGid)
					// 执行替换
					angular.forEach(m.data, function(r, index3){
					console.log(r.id)
						if(r.id == oldGid){
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							r.id = Gid;
							r.pic = artdata.pic;
							r.artid = artdata.id;
							r.name = artdata.name;
							r.subname = artdata.subname;
							r.createtime = date('Y-m-d H:i',artdata.createtime);
							r.readcount = artdata.readcount;
						}
					});
				}else if(!action){
					var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
					// 执行添加
					m.data.push({
						id: Gid,
						pic: artdata.pic,
						artid: artdata.id,
						name: artdata.name,
						subname: artdata.subname,
						createtime: date('Y-m-d H:i',artdata.createtime),
						readcount: artdata.readcount
					});
				}
			}
		});
	}


//预约服务商品
$scope.getyuyue = function(Mid) {
	angular.forEach($scope.Items, function(m, index1) {
		if (m.id == Mid) {
			var bid = m.params.bid
			var sortby = m.params.sortby
			var proshownum = m.params.proshownum
			var category = m.params.category
			$.ajax({
				type: 'post',
				dataType: 'json',
				url: "{:url('DesignerPage/api')}/op/selectyuyue",
				data: {
					bid: bid,
					sortby: sortby,
					proshownum: proshownum,
					cid: category,
				},
				success: function(data) {
					m.data = [];
					angular.forEach(data, function(d, i) {
						var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
						// 执行添加
						m.data.push({
							id: Gid,
							pic: data[i].pic,
							proid: data[i].id,
							name: data[i].name,
							sell_price: data[i].sell_price,
							danwei:data[i].danwei,
						});
					});
					$("div[mid=" + Mid + "]").mouseover();
				},
				error: function() {
					layer.msg('查询商品信息失败！请刷新页面。');
				}
			});
		}
	});
}
$scope.addyuyue = function(action, Mid, Gid) {
	layer.open({type:2,shadeClose:true,area:['920px', '560px'],'title':'选择服务',content:"{:url('YuyueList/chooseproduct')}/args/"+action+','+Mid+','+Gid});
}
$scope.delyuyue = function(Mid, Gid) {
	var Items = $scope.Items;
	angular.forEach(Items, function(m, index1) {
		if (m.id == Mid) {
			angular.forEach(m.data, function(g, index2) {
				if (g.id == Gid) {
					m.data.splice(index2, 1);
				}
			});
		}
	});
}
$scope.pushyuyue = function(prodata,args){
	var argsArr = args.split(',');
	var action = argsArr[0];
	var Mid = argsArr[1];
	var oldGid = argsArr[2];
	angular.forEach($scope.Items, function(m, index1) {
		if(m.id == Mid){
			if(action == 'replace' && oldGid){
				// 执行替换
				angular.forEach(m.data, function(r, index3){
					if(r.id == oldGid){
						var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
						r.id = Gid;
						r.pic = prodata.pic;
						r.proid = prodata.id;
						r.name = prodata.name;
						r.sell_price = prodata.sell_price;
						r.sales = prodata.sales;
					}
				});
			}else if(!action){
				var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
				// 执行添加
				m.data.push({
					id: Gid,
					pic: prodata.pic,
					proid: prodata.id,
					name: prodata.name,
					sell_price: prodata.sell_price,
				});
			}
		}
	});
}

	$scope.getcoupon = function(Mid) {
		angular.forEach($scope.Items, function(m, index1) {
			if (m.id == Mid) {
				var bid = m.params.bid
				var category = m.params.category
				var sortby = m.params.sortby
				var shownum = m.params.shownum
				$.ajax({
					type: 'post',
					dataType: 'json',
					url: "{:url('DesignerPage/api')}/op/selectcoupon",
					data: {
						bid: bid,
						cid: category,
						sortby: sortby,
						shownum: shownum
					},
					success: function(data) {
						m.data = [];
						angular.forEach(data, function(d, i) {
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							// 执行添加
							m.data.push({
								id: Gid,
								couponid: data[i].id,
								type: data[i].type,
								limit_count: data[i].limit_count,
								name: data[i].name,
								money: data[i].money,
								minprice: data[i].minprice,
								starttime: date('Y-m-d H:i',data[i].starttime),
								endtime: date('Y-m-d H:i',data[i].endtime)
							});
						});
						$("div[mid=" + Mid + "]").mouseover();
					},
					error: function() {
						layer.msg('查询信息失败！请刷新页面。');
					}
				});
			}
		});
	}
	$scope.addcoupon = function(action, Mid, Gid) {
		console.log(Gid)
		layer.open({type:2,shadeClose:true,area:['920px', '560px'],'title':'选择{:t('优惠券')}',content:"{:url('Coupon/choosecoupon')}/args/"+action+','+Mid+','+Gid});
	}
	$scope.delcoupon = function(Mid, Gid) {
		var Items = $scope.Items;
		angular.forEach(Items, function(m, index1) {
			if (m.id == Mid) {
				angular.forEach(m.data, function(g, index2) {
					if (g.couponid == Gid) {
						m.data.splice(index2, 1);
					}
				});
			}
		});
	}
	$scope.pushcoupon = function(coupondata,args){
		var argsArr = args.split(',');
		var action = argsArr[0];
		var Mid = argsArr[1];
		var oldGid = argsArr[2];
		console.log(coupondata)
		angular.forEach($scope.Items, function(m, index1) {
			if(m.id == Mid){
				if(action == 'replace' && oldGid){
					console.log(oldGid)
					// 执行替换
					angular.forEach(m.data, function(r, index3){
						if(r.id == oldGid){
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							r.id = Gid;
							r.couponid = coupondata.id;
							r.type = coupondata.type;
							r.limit_count = coupondata.limit_count;
							r.name = coupondata.name;
							r.money = coupondata.money;
							r.minprice = coupondata.minprice;
							r.starttime = date('Y-m-d H:i',coupondata.starttime);
							r.endtime = date('Y-m-d H:i',coupondata.endtime);
						}
					});
				}else if(!action){
					var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
					// 执行添加
					m.data.push({
						id: Gid,
						couponid: coupondata.id,
						type: coupondata.type,
						limit_count: coupondata.limit_count,
						name: coupondata.name,
						money: coupondata.money,
						minprice: coupondata.minprice,
						starttime: date('Y-m-d H:i',coupondata.starttime),
						endtime: date('Y-m-d H:i',coupondata.endtime)
					});
				}
			}
		});
	}
	$scope.addform = function(Mid){
		layer.open({type:2,shadeClose:true,area:['920px', '560px'],'title':'选择表单',content:"{:url('Form/chooseform')}/args/"+Mid});
	}
	$scope.pushform = function(Mid,formdata){
		angular.forEach($scope.Items, function(m, index1) {
			if(m.id == Mid){
				formdata.content = $.parseJSON(formdata.content);
				m.data = formdata
				console.log(m.data)
			}
		});
	}

	//洗鞋商品
	$scope.getxixie = function(Mid) {
		angular.forEach($scope.Items, function(m, index1) {
			if (m.id == Mid) {
				var bid = m.params.bid
				var category = m.params.category
				var sortby = m.params.sortby
				var proshownum = m.params.proshownum
				$.ajax({
					type: 'post',
					dataType: 'json',
					url: "{:url('DesignerPage/api')}/op/selectxixie",
					data: {
						bid: bid,
						cid: category,
						sortby: sortby,
						proshownum: proshownum
					},
					success: function(data) {
						m.data = [];
						angular.forEach(data, function(d, i) {
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							// 执行添加
							m.data.push({
								id: Gid,
								pic: data[i].pic,
								proid: data[i].id,
								name: data[i].name,
								sell_price: data[i].sell_price,
								vip_price: data[i].vip_price,
							});
						});
						$("div[mid=" + Mid + "]").mouseover();
					},
					error: function() {
						layer.msg('查询商品信息失败！请刷新页面。');
					}
				});
			}
		});
	}
	$scope.addxixie = function(action, Mid, Gid) {
		layer.open({type:2,shadeClose:true,area:['920px', '560px'],'title':'选择商品',content:"{:url('CollageProduct/chooseproduct')}/args/"+action+','+Mid+','+Gid});
	}
	$scope.delxixie = function(Mid, Gid) {
		var Items = $scope.Items;
		angular.forEach(Items, function(m, index1) {
			if (m.id == Mid) {
				angular.forEach(m.data, function(g, index2) {
					if (g.id == Gid) {
						m.data.splice(index2, 1);
					}
				});
			}
		});
	}
	$scope.pushxixie = function(prodata,args){
		var argsArr = args.split(',');
		var action = argsArr[0];
		var Mid = argsArr[1];
		var oldGid = argsArr[2];
		angular.forEach($scope.Items, function(m, index1) {
			if(m.id == Mid){
				if(action == 'replace' && oldGid){
					// 执行替换
					angular.forEach(m.data, function(r, index3){
						if(r.id == oldGid){
							var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
							r.id = Gid;
							r.pic = prodata.pic;
							r.proid = prodata.id;
							r.name = prodata.name;
							r.sell_price = prodata.sell_price;
							r.vip_price = prodata.vip_price;
						}
					});
				}else if(!action){
					var Gid = 'G' + new Date().getTime() + parseInt(Math.random() * 1000000);
					// 执行添加
					m.data.push({
						id: Gid,
						pic: prodata.pic,
						proid: prodata.id,
						name: prodata.name,
						sell_price: prodata.sell_price,
						vip_price: prodata.vip_price,
					});
				}
			}
		});
	}

	$scope.load = function() {
		console.log(11)
	}
	$scope.changeImg = function(Mid, n) {
		width = parseInt($(".dsn-mod-move").width());
		height = (width * parseInt(n.replace("%", "")) / 100) - 16;
		$("div[mid=" + Mid + "] .dsn-8-main-img img").height(height);
	};
	$scope.setimg = function(Mid, n) {
		width = $(".dsn-mod-move").width();
		n = n.replace("%", "");
		n = n / 100;
		$("div[mid=" + Mid + "] .dsn-12 img").height(width * n - 30);
	}
	$scope.setfocus = function(Mid, e) {
		$scope.focus = Mid;
		//ccc = $("div[id=" + Mid + "]").offset().top;
		//ddd = (ccc - 280) >= 0 ? (ccc - 280) : 0;
	}
	$scope.addItem = function(Nid) {
		var Mid = 'M' + new Date().getTime() + parseInt(Math.random() * 1000000);
		var Navs = $scope.navs;
		angular.forEach(Navs, function(n, index) {
			if (n.id == Nid) {
				newparams = !clone(n.params) ? '' : clone(n.params);
				newdata = !n.data ? '' : cloneArr(n.data);
				newother = !clone(n.other) ? '' : clone(n.other);
				newcontent = !clone(n.content) ? '' : clone(n.content);
				if (Nid == 'cube') {
					for (row = 0; row < 4; row++) {
						for (newparams.layout[row] = {}, col = 0; col < 4; col++) {
							newparams.layout[row][col] = {cols: 1,rows: 1,isempty: !0,imgurl: "",classname: ""};
						}
					}
				}
				var newitem = {id: Mid,temp: Nid,params: newparams,data: newdata,other: newother,content: newcontent};
				var insertindex = -1;
				if ($scope.focus != '') {
					var Items = $scope.Items;
					angular.forEach(Items, function(a, index) {
						if (a.id == $scope.focus) {
							insertindex = index;
						}
					});
				}
				if (insertindex == -1) {
					$scope.Items.push(newitem);
				} else {
					$scope.Items.splice(insertindex + 1, 0, newitem);
				}
				$scope.focus = newitem.id;
				if(Nid == 'product'){
					$scope.getgoods(newitem.id);
				}
				if(Nid == 'collage'){
					$scope.getcollage(newitem.id);
				}
				if(Nid == 'cycle'){
					$scope.getcycle(newitem.id);
				}
				if(Nid == 'luckycollage'){
					$scope.getluckycollage(newitem.id);
				}
				if(Nid == 'kanjia'){
					$scope.getkanjia(newitem.id);
				}
				if(Nid == 'seckill'){
					$scope.getseckill(newitem.id);
				}
				if(Nid == 'scoreshop'){
					$scope.getscoreshop(newitem.id);
				}
				if(Nid == 'restaurant_product'){
					$scope.getRestaurantGoods(newitem.id);
				}
				if(Nid == 'article'){
					$scope.getarticle(newitem.id);
				}
				if(Nid == 'coupon'){
					$scope.getcoupon(newitem.id);
				}
				if(Nid == 'business'){
					$scope.getbusiness(newitem.id);
				}
				if(Nid == 'shortvideo'){
					$scope.getshortvideo(newitem.id);
				}
				if(Nid == 'liveroom'){
					$scope.getliveroom(newitem.id);
				}
				if(Nid == 'yuyue'){
					$scope.getyuyue(newitem.id);
				}
				if(Nid == 'tuangou'){
					$scope.gettuangou(newitem.id);
				}
				if(Nid == 'kecheng'){
					$scope.getKecheng(newitem.id);
				}
				if(Nid == 'zhaopin'){
					$scope.getZhaopin(newitem.id);
				}
				if(Nid == 'qiuzhi'){
					$scope.getQiuzhi(newitem.id);
				}
				if(Nid == 'xixie'){
					$scope.getxixie(newitem.id);
				}
			}
		});
	}

	$scope.delItem = function(id) {
		var Items = $scope.Items;
		angular.forEach(Items, function(a, index) {
			if (a.id == id) {
				Items.splice(index, 1);
				$scope.focus = '';
				layer.msg('移除成功');
			}
		});
	}
	$scope.over = function(id){
		$("div[id=" + id + "]").parent().find(".dsn-del").stop().show();
	}
	$scope.out = function(id){
		$("div[id=" + id + "]").parent().find(".dsn-del").stop().hide();
	}
	$scope.shopImg = function(Mid){
		fileUploader.show(function(data){
			var Items = $scope.Items;
			angular.forEach(Items, function(m, index1){
				if(m.id == Mid){
					m.params.bgimg = data['url'];
					$("div[mid=" + Mid + "]").mouseover();
				}
			});
		},{type: 'image'});
	}
	$scope.pageImg = function(Mid, type){
		fileUploader.show(function(data){
			if(type == 'floatimg'){
				$scope.pages[0].params.floatimg = data['url'];
			}else{
				$scope.pages[0].params.img = data['url'];
			}
			$("div[mid=" + Mid + "]").trigger("click");
		},{type:'image'});
	}

	$scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {
		console.log('ngRepeatFinished')
		layui.form.render();
		$('.dsn-banner .swipe').each(function() {
			initswipe($(this));
		})
		angular.forEach($scope.Items, function(m, index1) {
			if(m.temp == 'map'){
				var center = new qq.maps.LatLng(m.params.latitude,m.params.longitude);
				var map = new qq.maps.Map(document.getElementById("showmp_"+m.id), {
					center: center,      // 地图的中心地理坐标。
					zoom:15              // 地图的中心地理坐标。
				});
				var marker = new qq.maps.Marker({ position:center, map: map});
			}
		})
		//$("div[mid=" + Mid + "]").mouseover();
	});

	$scope.getdata = function(n) {
		var items = cloneArr($scope.Items);
		angular.forEach(items, function(m, index1) {
			if (m.temp == 'richtext') {
				m.content = escape(m.content);
			}
		});
		var datas = angular.toJson(items);
		var pageinfo = angular.toJson($scope.pages);
		return {'datainfo': datas,'pageinfo': pageinfo};
	}
}]);

myModel.directive('stringHtml', function() {
	return function(scope, el, attr) {
		if (attr.stringHtml) {
			scope.$watch(attr.stringHtml, function(html) {
				el.html(html || '');
			});
		}
	};
});

myModel.directive("onFinishRenderFilters", function($timeout) {
	return {
		restrict: 'A',
		link: function(scope, element, attr) {
			if (scope.$last === true) {
				$timeout(function() {
					if(ngisfinish==0){
						layui.form.render();
					}
					ngisfinish = 1;
					scope.$emit('ngRepeatFinished');
				});
			}
		}
	};
});
$(function(){
	changeconentxy();
	$(window).scroll(function(){
		changeconentxy();
	});
	layui.form.render();
})

function changeconentxy(){
		var $scope = angular.element(document.querySelector('[ng-controller=FoxController]')).scope();
		$scope.contenttop = $('#editor-content').offset().top - $(window).scrollTop();
		$scope.contentleft = $('#editor-content').offset().left - $(window).scrollLeft();
		$scope.$apply();
}

function choosepro(prodata,args) {
	var $scope = angular.element(document.querySelector('[ng-controller=FoxController]')).scope();
	$scope.pushGood(prodata.product,args);
	$scope.$apply();
}
function choosescoreshop(prodata,args) {
	var $scope = angular.element(document.querySelector('[ng-controller=FoxController]')).scope();
	$scope.pushscoreshop(prodata,args);
	$scope.$apply();
}
function choosecollage(prodata,args) {
	var $scope = angular.element(document.querySelector('[ng-controller=FoxController]')).scope();
	$scope.pushcollage(prodata,args);
	$scope.$apply();
}
function chooseluckycollage(prodata,args) {
	var $scope = angular.element(document.querySelector('[ng-controller=FoxController]')).scope();
	$scope.pushluckycollage(prodata,args);
	$scope.$apply();
}
function choosekanjia(prodata,args) {
	var $scope = angular.element(document.querySelector('[ng-controller=FoxController]')).scope();
	$scope.pushkanjia(prodata,args);
	$scope.$apply();
}
function chooseseckill(prodata,args) {
	var $scope = angular.element(document.querySelector('[ng-controller=FoxController]')).scope();
	$scope.pushseckill(prodata,args);
	$scope.$apply();
}
function choosetuangou(prodata,args) {
	var $scope = angular.element(document.querySelector('[ng-controller=FoxController]')).scope();
	$scope.pushTuangou(prodata,args);
	$scope.$apply();
}
function chooseArticle(artdata,args) {
	var $scope = angular.element(document.querySelector('[ng-controller=FoxController]')).scope();
	$scope.pushArticle(artdata,args);
	$scope.$apply();
}
function choosecoupon(cpdata,args){
	var $scope = angular.element(document.querySelector('[ng-controller=FoxController]')).scope();
	$scope.pushcoupon(cpdata,args);
	$scope.$apply();
}
function chooseform(formdata,args){
	console.log(args)
	var $scope = angular.element(document.querySelector('[ng-controller=FoxController]')).scope();
	$scope.pushform(args,formdata);
	$scope.$apply();
}
function choosebusiness(prodata,args) {
	var $scope = angular.element(document.querySelector('[ng-controller=FoxController]')).scope();
	$scope.pushbusiness(prodata,args);
	$scope.$apply();
}
function chooseliveroom(prodata,args) {
	var $scope = angular.element(document.querySelector('[ng-controller=FoxController]')).scope();
	$scope.pushliveroom(prodata,args);
	$scope.$apply();
}
function chooseLink(urlname,url,args) {
	//url =  url + (url.indexOf('?') > -1 ? '&' : '?') + 'x={$x}';
	var $scope = angular.element(document.querySelector('[ng-controller=FoxController]')).scope();
	$scope.chooseLink(urlname,url,args);
	$scope.$apply();
}
function chooseshortvideo(prodata,args) {
	var $scope = angular.element(document.querySelector('[ng-controller=FoxController]')).scope();
	$scope.pushshortvideo(prodata.product,args);
	$scope.$apply();
}
//预约服务
function chooseyuyue(prodata,args) {
	var $scope = angular.element(document.querySelector('[ng-controller=FoxController]')).scope();
	$scope.pushyuyue(prodata.product,args);
	$scope.$apply();
}

function choosekecheng(prodata,args) {
	var $scope = angular.element(document.querySelector('[ng-controller=FoxController]')).scope();
	$scope.pushKecheng(prodata.product,args);
	$scope.$apply();
}

function geteditordata() {
	//通过controller来获取Angular应用
	var appElement = document.querySelector('[ng-controller=FoxController]');
	//获取$scope变量
	var $scope = angular.element(appElement).scope();
	return $scope.getdata()
}
function choosexixie(prodata,args) {
	var $scope = angular.element(document.querySelector('[ng-controller=FoxController]')).scope();
	$scope.pushxixie(prodata,args);
	$scope.$apply();
}

</script>

